Skip to content

Commit 6315334

Browse files
authored
[MongoDB Storage] Increase timeouts for checksums from 40s -> 80s (#338)
* Increase timeouts for checksums from 40s -> 80s. * Changeset.
1 parent 7852eb7 commit 6315334

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

.changeset/silver-keys-confess.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@powersync/service-module-mongodb-storage': patch
3+
'@powersync/lib-service-mongodb': patch
4+
'@powersync/service-core': patch
5+
'@powersync/service-image': patch
6+
---
7+
8+
[MongoDB Storage] Increase checksum timeouts

libs/lib-mongodb/src/db/mongo.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ export const MONGO_CONNECT_TIMEOUT_MS = 10_000;
99

1010
/**
1111
* Time for individual requests to timeout the socket.
12+
*
13+
* Currently increased to cater for slow checksum calculations - may be reduced to 60s again
14+
* if we optimize those.
1215
*/
13-
export const MONGO_SOCKET_TIMEOUT_MS = 60_000;
16+
export const MONGO_SOCKET_TIMEOUT_MS = 90_000;
1417

1518
/**
1619
* Time for individual requests to timeout the operation.
@@ -21,6 +24,18 @@ export const MONGO_SOCKET_TIMEOUT_MS = 60_000;
2124
*/
2225
export const MONGO_OPERATION_TIMEOUT_MS = 40_000;
2326

27+
/**
28+
* Time for individual checksums requests to timeout the operation.
29+
*
30+
* This is time spent on the cursor, not total time.
31+
*
32+
* Must be less than MONGO_SOCKET_TIMEOUT_MS to ensure proper error handling.
33+
*
34+
* This is temporarily increased to cater for slow checksum calculations,
35+
* may be reduced to MONGO_OPERATION_TIMEOUT_MS again if we optimize those.
36+
*/
37+
export const MONGO_CHECKSUM_TIMEOUT_MS = 80_000;
38+
2439
/**
2540
* Same as above, but specifically for clear operations.
2641
*

modules/module-mongodb-storage/src/storage/implementation/MongoSyncBucketStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ export class MongoSyncBucketStorage
537537
}
538538
}
539539
],
540-
{ session: undefined, readConcern: 'snapshot', maxTimeMS: lib_mongo.db.MONGO_OPERATION_TIMEOUT_MS }
540+
{ session: undefined, readConcern: 'snapshot', maxTimeMS: lib_mongo.db.MONGO_CHECKSUM_TIMEOUT_MS }
541541
)
542542
.toArray()
543543
.catch((e) => {

0 commit comments

Comments
 (0)