fix: use start_after instead of resume_after for change stream tokens if MongoDB version >= 4.2 #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This tap has had some issues in log-based replication mode and I've been trying to chase those down and make this resilient in the face of all scenarios. This PR updates the "resume change stream" handling that is used when the tap is running in log-based mode using a saved bookmark (that is, when not in "full refresh" mode).
Previously the tap was passing the saved resume token from the meltano state to the "open change stream" command in the
resume_after
field. This field is supported by all versions of MongoDB change streams (MongoDB 3.6 and above).In MongoDB 4.2, a new
start_after
field was added to the "open change stream" command. This is preferable toresume_after
for this tap's use cases, so this PR uses thestart_after
field if the MongoDB version is 4.2 or greater.Why is
start_after
preferable? See the docs: https://www.mongodb.com/docs/manual/changeStreams/#startafter-for-change-streams But tl;dr: If a given resume token is not present in the oplog (which can happen if this tap has not been run in X hours, where X > oplog headroom in hours),start_after
will gracefully open a new change stream, whileresume_after
will error.