Skip to content

Conversation

rkistner
Copy link
Contributor

@rkistner rkistner commented Sep 1, 2025

This fixes two more issues introduced in #343:

  1. The populatePersistentChecksumCache method did not filter according to the group_id (sync rules version) when determining which buckets to update. This was mostly harmless on its own apart from performance overhead, except when combined with the next issue.
  2. When compacting or calling populatePersistentChecksumCache, if the bucket_state did not exist already, we created it with last_op: <compact-checkpoint>. The issue is this is different from how last_op is usually updated, and violates an unique index when re-using the same last_op across multiple buckets.

This resulted in errors such as this:

Replication error E11000 duplicate key error collection: powersync_demo.bucket_state index: bucket_updates dup key: { _id.g: 27, last_op: 16347291 }

This could happen either when:

  1. Deploying sync rule changes.
  2. Compacting buckets.

This fixes both issues.

@rkistner rkistner requested a review from simolus3 September 1, 2025 15:54
Copy link

changeset-bot bot commented Sep 1, 2025

🦋 Changeset detected

Latest commit: 6c61b31

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

This PR includes changesets to release 11 packages
Name Type
@powersync/service-module-mongodb-storage Patch
@powersync/service-core Patch
@powersync/service-image Patch
@powersync/service-schema Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres Patch
@powersync/service-core-tests Patch
@powersync/service-module-core Patch
@powersync/service-module-postgres-storage Patch
test-client 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

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.

LGTM 👍

@rkistner rkistner merged commit bec7496 into main Sep 1, 2025
21 checks passed
@rkistner rkistner deleted the compact-fixes branch September 1, 2025 16:21
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