Skip to content

Commit 725daa1

Browse files
authored
[MongoDB Storage] Checksum calculation improvements (#346)
* Add additional checksum tests. * Fix bug with partial batched checksums. * Split up storage tests. * Merge the two checksum implementations. * Changeset. * Rename methods and add more comments.
1 parent d557ec8 commit 725daa1

File tree

18 files changed

+1265
-1032
lines changed

18 files changed

+1265
-1032
lines changed

.changeset/wicked-rockets-add.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@powersync/service-module-postgres-storage': patch
3+
'@powersync/service-module-mongodb-storage': patch
4+
'@powersync/service-core-tests': patch
5+
'@powersync/service-image': patch
6+
---
7+
8+
Fix rare issue of incorrect checksums on fallback after checksum query timed out.

modules/module-mongodb-storage/src/storage/MongoBucketStorage.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { mongo } from '@powersync/lib-service-mongodb';
1111
import { PowerSyncMongo } from './implementation/db.js';
1212
import { SyncRuleDocument } from './implementation/models.js';
1313
import { MongoPersistedSyncRulesContent } from './implementation/MongoPersistedSyncRulesContent.js';
14-
import { MongoSyncBucketStorage } from './implementation/MongoSyncBucketStorage.js';
14+
import { MongoSyncBucketStorage, MongoSyncBucketStorageOptions } from './implementation/MongoSyncBucketStorage.js';
1515
import { generateSlotName } from './implementation/util.js';
1616

1717
export class MongoBucketStorage
@@ -31,7 +31,8 @@ export class MongoBucketStorage
3131
db: PowerSyncMongo,
3232
options: {
3333
slot_name_prefix: string;
34-
}
34+
},
35+
private internalOptions?: MongoSyncBucketStorageOptions
3536
) {
3637
super();
3738
this.client = db.client;
@@ -49,7 +50,7 @@ export class MongoBucketStorage
4950
if ((typeof id as any) == 'bigint') {
5051
id = Number(id);
5152
}
52-
const storage = new MongoSyncBucketStorage(this, id, syncRules, slot_name);
53+
const storage = new MongoSyncBucketStorage(this, id, syncRules, slot_name, undefined, this.internalOptions);
5354
if (!options?.skipLifecycleHooks) {
5455
this.iterateListeners((cb) => cb.syncStorageCreated?.(storage));
5556
}

0 commit comments

Comments
 (0)