Skip to content

Conversation

rkistner
Copy link
Contributor

This includes some minor performance and stability improvements from the MongoDB driver:

  1. Fix resumeTokens going back in time when streaming changes from the source database (https://jira.mongodb.org/browse/NODE-7042 / fix(NODE-4763): cache resumeToken in ChangeStream.tryNext() mongodb/node-mongodb-native#4636). We implemented a workaround in [MongoDB Replication] Fix resumeTokens going back in time on busy change streams #301, but the workaround could still result in replication delays when the bug was hit. This fixes it properly.
  2. fix(NODE-6858): treat MongoServerSelectionError as a resumable error for Change Streams mongodb/node-mongodb-native#4653 - can result in faster resumption of streaming changes
  3. feat(NODE-7140): deprecate driver info options mongodb/node-mongodb-native#4654 - will affect how we report metadata to mongodb in the future
  4. feat(NODE-6472): findOne and find no longer keep open cursors mongodb/node-mongodb-native#4580 - sets batchSize to limit + 1 to avoid leaving open cursors or requiring an explicit cursor close. I updated our code to do the same to be explicit about this. This may give small performance improvements and reduced mongodb memory usage.
  5. fix(NODE-6589): background task does not prune idle connections when minPoolSize=0 mongodb/node-mongodb-native#4569 - allows closing idle connections, which could reduce bucket storage resource usage on idle instances (we use the default of minPoolSize: 0)

Copy link

changeset-bot bot commented Oct 14, 2025

🦋 Changeset detected

Latest commit: 45848cc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@powersync/service-module-mongodb-storage Patch
@powersync/service-rsocket-router Patch
@powersync/service-module-mongodb Patch
@powersync/service-core Patch
@powersync/lib-services-framework Patch
@powersync/lib-service-mongodb Patch
@powersync/service-schema Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres Patch
@powersync/service-image Patch
@powersync/service-module-core Patch
@powersync/service-core-tests Patch
@powersync/service-module-postgres-storage Patch
test-client Patch
@powersync/lib-service-postgres Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner rkistner requested a review from simolus3 October 14, 2025 08:54
Copy link
Contributor

@simolus3 simolus3 left a comment

Choose a reason for hiding this comment

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

For my understanding, we have to increase batchSize by one because we're using a lower-level API that sidesteps the client driver logic in operations/find.ts?

I didn't check whether there are any batchSize uses left we may have to migrate, but since this doesn't affect correctness it looks good to me.

@rkistner
Copy link
Contributor Author

The change is not actually required. The new driver version implements that same change automatically - basically if (batchSize == limit) { batchSize = limit + 1 }. The change in the code here is just to make it more explicit that that is what is happening, to avoid wondering why the server is receiving a different batchSize from what we're sending.

@rkistner rkistner merged commit da7ecc6 into main Oct 14, 2025
21 checks passed
@rkistner rkistner deleted the upgrade-mongodb-driver branch October 14, 2025 09:55
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