Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use start_after instead of resume_after for change stream tokens if MongoDB version >= 4.2 #23

Merged
merged 3 commits into from
Oct 18, 2023

Conversation

menzenski
Copy link
Contributor

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 to resume_after for this tap's use cases, so this PR uses the start_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, while resume_after will error.

@menzenski menzenski self-assigned this Oct 18, 2023
@menzenski menzenski merged commit d716052 into MeltanoLabs:main Oct 18, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants