Skip to content

Commit

Permalink
[hotfix][cdc-connector][mongodb] Fix scanFullChangelog requires all c…
Browse files Browse the repository at this point in the history
…ollections
  • Loading branch information
yuxiqian authored Jan 30, 2024
1 parent 7ea1972 commit 82ccf00
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,17 @@ public static ChangeStreamIterable<Document> getChangeStreamIterable(
}

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);
}
Expand Down

0 comments on commit 82ccf00

Please sign in to comment.