diff --git a/.changeset/silver-keys-confess.md b/.changeset/silver-keys-confess.md new file mode 100644 index 000000000..2893a0c80 --- /dev/null +++ b/.changeset/silver-keys-confess.md @@ -0,0 +1,8 @@ +--- +'@powersync/service-module-mongodb-storage': patch +'@powersync/lib-service-mongodb': patch +'@powersync/service-core': patch +'@powersync/service-image': patch +--- + +[MongoDB Storage] Increase checksum timeouts diff --git a/libs/lib-mongodb/src/db/mongo.ts b/libs/lib-mongodb/src/db/mongo.ts index b8f8ff170..6bd1f1a79 100644 --- a/libs/lib-mongodb/src/db/mongo.ts +++ b/libs/lib-mongodb/src/db/mongo.ts @@ -9,8 +9,11 @@ export const MONGO_CONNECT_TIMEOUT_MS = 10_000; /** * Time for individual requests to timeout the socket. + * + * Currently increased to cater for slow checksum calculations - may be reduced to 60s again + * if we optimize those. */ -export const MONGO_SOCKET_TIMEOUT_MS = 60_000; +export const MONGO_SOCKET_TIMEOUT_MS = 90_000; /** * Time for individual requests to timeout the operation. @@ -21,6 +24,18 @@ export const MONGO_SOCKET_TIMEOUT_MS = 60_000; */ export const MONGO_OPERATION_TIMEOUT_MS = 40_000; +/** + * Time for individual checksums requests to timeout the operation. + * + * This is time spent on the cursor, not total time. + * + * Must be less than MONGO_SOCKET_TIMEOUT_MS to ensure proper error handling. + * + * This is temporarily increased to cater for slow checksum calculations, + * may be reduced to MONGO_OPERATION_TIMEOUT_MS again if we optimize those. + */ +export const MONGO_CHECKSUM_TIMEOUT_MS = 80_000; + /** * Same as above, but specifically for clear operations. * diff --git a/modules/module-mongodb-storage/src/storage/implementation/MongoSyncBucketStorage.ts b/modules/module-mongodb-storage/src/storage/implementation/MongoSyncBucketStorage.ts index 58e58b4dd..d7f824f7f 100644 --- a/modules/module-mongodb-storage/src/storage/implementation/MongoSyncBucketStorage.ts +++ b/modules/module-mongodb-storage/src/storage/implementation/MongoSyncBucketStorage.ts @@ -537,7 +537,7 @@ export class MongoSyncBucketStorage } } ], - { session: undefined, readConcern: 'snapshot', maxTimeMS: lib_mongo.db.MONGO_OPERATION_TIMEOUT_MS } + { session: undefined, readConcern: 'snapshot', maxTimeMS: lib_mongo.db.MONGO_CHECKSUM_TIMEOUT_MS } ) .toArray() .catch((e) => {