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

feat(NODE-5243): add change stream split event #3745

Merged
merged 5 commits into from Jun 28, 2023
Merged

Conversation

durran
Copy link
Member

@durran durran commented Jun 27, 2023

Description

Adds support for change stream split events.

What is changing?

Is there new documentation needed for these changes?

None

What is the motivation for this change?

NODE-5243

Release Highlight

Support for change stream split events

When change stream documents exceed the max BSON size limit of 16MB, they can be split into multiple fragments in order to not error when sending events over the wire. In order to enable this functionality, the collection must be created with changeStreamPreAndPostImages enabled and the change stream itself must include an $changeStreamSplitLargeEvent aggregation stage. This feature requires a minimum server version of 7.0.0.

Example:

await db.createCollection('test', { changeStreamPreAndPostImages: { enabled: true }});
const collection = db.collection('test');
const changeStream = collection.watch([{ $changeStreamSplitLargeEvent: {} ], {
  fullDocumentBeforeChange: 'required'
});

for await (const change of changeStream) {
  console.log(change.splitEvent); // If changes over 16MB: { fragment: n, of: n }
}

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@durran durran marked this pull request as ready for review June 27, 2023 20:32
@baileympearson baileympearson self-assigned this Jun 27, 2023
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jun 27, 2023
Copy link
Contributor

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment, LGTM

// Collect two events from _S_.
const eventOne = await changeStream.next();
const eventTwo = await changeStream.next();
await changeStream.close();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move the close logic here into the afterEach hook?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@baileympearson baileympearson merged commit 1c84f82 into main Jun 28, 2023
23 of 26 checks passed
@baileympearson baileympearson deleted the NODE-5243 branch June 28, 2023 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Primary Review In Review with primary reviewer, not yet ready for team's eyes
Projects
None yet
2 participants