[hotfix][cdc-connector][mongodb] Fix scanFullChangelog requires all collections

pull/3050/head
yuxiqian 1 year ago committed by GitHub
parent 7ea197242f
commit 82ccf00e6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -222,9 +222,17 @@ public class MongoUtils {
}
if (fullDocPrePostImage) {
// require both pre-image and post-image
changeStream.fullDocument(FullDocument.REQUIRED);
changeStream.fullDocumentBeforeChange(FullDocumentBeforeChange.REQUIRED);
if (StringUtils.isNotEmpty(database) && StringUtils.isNotEmpty(collection)) {
// require both pre-image and post-image records
changeStream.fullDocument(FullDocument.REQUIRED);
changeStream.fullDocumentBeforeChange(FullDocumentBeforeChange.REQUIRED);
} else {
// for RegEx limited namespaces, use WHEN_AVAILABLE option
// to avoid MongoDB complaining about missing pre- and post-image
// coming from irrelevant collections
changeStream.fullDocument(FullDocument.WHEN_AVAILABLE);
changeStream.fullDocumentBeforeChange(FullDocumentBeforeChange.WHEN_AVAILABLE);
}
} else if (updateLookup) {
changeStream.fullDocument(FullDocument.UPDATE_LOOKUP);
}

Loading…
Cancel
Save