@powersync/service-module-mongodb-storage 0.23.1 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/LICENSE +201 -67
- package/dist/storage/MongoBucketStorage.d.ts +1 -0
- package/dist/storage/MongoBucketStorage.js +3 -0
- package/dist/storage/MongoBucketStorage.js.map +1 -1
- package/dist/storage/implementation/MongoBucketBatch.d.ts +60 -39
- package/dist/storage/implementation/MongoBucketBatch.js +123 -296
- package/dist/storage/implementation/MongoBucketBatch.js.map +1 -1
- package/dist/storage/implementation/MongoOpIdAllocator.d.ts +6 -1
- package/dist/storage/implementation/MongoOpIdAllocator.js +12 -5
- package/dist/storage/implementation/MongoOpIdAllocator.js.map +1 -1
- package/dist/storage/implementation/MongoParsedSyncConfigSet.d.ts +7 -0
- package/dist/storage/implementation/MongoParsedSyncConfigSet.js +28 -2
- package/dist/storage/implementation/MongoParsedSyncConfigSet.js.map +1 -1
- package/dist/storage/implementation/MongoReplicationOptions.d.ts +27 -0
- package/dist/storage/implementation/MongoReplicationOptions.js +26 -0
- package/dist/storage/implementation/MongoReplicationOptions.js.map +1 -0
- package/dist/storage/implementation/MongoSyncBucketStorage.js +2 -3
- package/dist/storage/implementation/MongoSyncBucketStorage.js.map +1 -1
- package/dist/storage/implementation/MongoSyncRulesLock.d.ts +15 -2
- package/dist/storage/implementation/MongoSyncRulesLock.js +36 -14
- package/dist/storage/implementation/MongoSyncRulesLock.js.map +1 -1
- package/dist/storage/implementation/common/BatchOperationBuffer.d.ts +79 -0
- package/dist/storage/implementation/common/BatchOperationBuffer.js +286 -0
- package/dist/storage/implementation/common/BatchOperationBuffer.js.map +1 -0
- package/dist/storage/implementation/common/PersistedBatch.d.ts +10 -103
- package/dist/storage/implementation/common/PersistedBatch.js +1 -291
- package/dist/storage/implementation/common/PersistedBatch.js.map +1 -1
- package/dist/storage/implementation/common/PreparedPublication.d.ts +43 -0
- package/dist/storage/implementation/common/PreparedPublication.js +2 -0
- package/dist/storage/implementation/common/PreparedPublication.js.map +1 -0
- package/dist/storage/implementation/common/SourceRecordStore.d.ts +0 -2
- package/dist/storage/implementation/v1/MongoBucketBatchV1.d.ts +17 -13
- package/dist/storage/implementation/v1/MongoBucketBatchV1.js +259 -18
- package/dist/storage/implementation/v1/MongoBucketBatchV1.js.map +1 -1
- package/dist/storage/implementation/v1/PersistedBatchV1.d.ts +21 -15
- package/dist/storage/implementation/v1/PersistedBatchV1.js +58 -24
- package/dist/storage/implementation/v1/PersistedBatchV1.js.map +1 -1
- package/dist/storage/implementation/v1/SourceRecordStoreV1.d.ts +0 -2
- package/dist/storage/implementation/v1/SourceRecordStoreV1.js +0 -3
- package/dist/storage/implementation/v1/SourceRecordStoreV1.js.map +1 -1
- package/dist/storage/implementation/v3/MongoBucketBatchV3.d.ts +25 -14
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js +350 -23
- package/dist/storage/implementation/v3/MongoBucketBatchV3.js.map +1 -1
- package/dist/storage/implementation/v3/MongoCompactorV3.d.ts +1 -0
- package/dist/storage/implementation/v3/MongoCompactorV3.js +10 -4
- package/dist/storage/implementation/v3/MongoCompactorV3.js.map +1 -1
- package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js +39 -28
- package/dist/storage/implementation/v3/MongoSyncBucketStorageV3.js.map +1 -1
- package/dist/storage/implementation/v3/PersistedBatchV3.d.ts +46 -24
- package/dist/storage/implementation/v3/PersistedBatchV3.js +159 -83
- package/dist/storage/implementation/v3/PersistedBatchV3.js.map +1 -1
- package/dist/storage/implementation/v3/SourceRecordStoreV3.d.ts +12 -0
- package/dist/storage/implementation/v3/SourceRecordStoreV3.js +41 -13
- package/dist/storage/implementation/v3/SourceRecordStoreV3.js.map +1 -1
- package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.d.ts +4 -0
- package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.js +4 -0
- package/dist/storage/implementation/v3/object-storage/BucketDataObjectStorage.js.map +1 -1
- package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.d.ts +27 -2
- package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.js +61 -5
- package/dist/storage/implementation/v3/object-storage/ObjectStorageLifecycle.js.map +1 -1
- package/package.json +9 -10
- package/src/storage/MongoBucketStorage.ts +4 -0
- package/src/storage/implementation/MongoBucketBatch.ts +185 -392
- package/src/storage/implementation/MongoOpIdAllocator.ts +12 -5
- package/src/storage/implementation/MongoParsedSyncConfigSet.ts +40 -1
- package/src/storage/implementation/MongoReplicationOptions.ts +28 -0
- package/src/storage/implementation/MongoSyncBucketStorage.ts +2 -3
- package/src/storage/implementation/MongoSyncRulesLock.ts +39 -17
- package/src/storage/implementation/common/BatchOperationBuffer.ts +353 -0
- package/src/storage/implementation/common/PersistedBatch.ts +12 -390
- package/src/storage/implementation/common/PreparedPublication.ts +49 -0
- package/src/storage/implementation/common/SourceRecordStore.ts +0 -2
- package/src/storage/implementation/v1/MongoBucketBatchV1.ts +339 -27
- package/src/storage/implementation/v1/PersistedBatchV1.ts +74 -32
- package/src/storage/implementation/v1/SourceRecordStoreV1.ts +0 -5
- package/src/storage/implementation/v3/MongoBucketBatchV3.ts +430 -32
- package/src/storage/implementation/v3/MongoCompactorV3.ts +13 -4
- package/src/storage/implementation/v3/MongoSyncBucketStorageV3.ts +43 -29
- package/src/storage/implementation/v3/PersistedBatchV3.ts +209 -108
- package/src/storage/implementation/v3/SourceRecordStoreV3.ts +45 -15
- package/src/storage/implementation/v3/object-storage/BucketDataObjectStorage.ts +9 -0
- package/src/storage/implementation/v3/object-storage/ObjectStorageLifecycle.ts +79 -5
- package/test/src/checkpoint_cleanup.test.ts +75 -0
- package/test/src/concurrent_writers.test.ts +127 -53
- package/test/src/helpers/PublicationCommandMonitor.ts +119 -0
- package/test/src/helpers/concurrentWriter.mjs +2 -2
- package/test/src/invalid_sync_config.test.ts +9 -0
- package/test/src/object_storage_lifecycle.test.ts +72 -2
- package/test/src/prepared_publication.test.ts +388 -0
- package/test/src/replication_preparation.test.ts +829 -0
- package/test/src/replication_publication_baseline.test.ts +203 -0
- package/test/src/replication_publication_batching.test.ts +212 -0
- package/test/src/replication_uploads.test.ts +393 -0
- package/test/src/source_table_config.test.ts +4 -4
- package/test/src/storage_object_storage_inline_threshold.test.ts +1 -1
- package/test/src/storage_s3_compaction_lifecycle.test.ts +93 -1
- package/test/src/storage_sync.test.ts +83 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mongo } from '@powersync/lib-service-mongodb';
|
|
1
2
|
import { Logger } from '@powersync/lib-services-framework';
|
|
2
3
|
import * as bson from 'bson';
|
|
3
4
|
import { MongoWriteBatch } from '../../MongoWriteBatch.js';
|
|
@@ -5,6 +6,12 @@ import { VersionedPowerSyncMongoV3 } from '../VersionedPowerSyncMongoV3.js';
|
|
|
5
6
|
import { BucketDataObjectStorage } from './BucketDataObjectStorage.js';
|
|
6
7
|
import { ObjectStorage, ObjectStorageOperationOptions } from './ObjectStorage.js';
|
|
7
8
|
export declare const OBJECT_STORAGE_UPLOAD_LEASE_MS: number;
|
|
9
|
+
/**
|
|
10
|
+
* Leave time for the bounded publication transaction and clock skew before
|
|
11
|
+
* cleanup can select a marker. Publication must finish within this margin after
|
|
12
|
+
* its eligibility check; checked marker deletion alone cannot protect an object
|
|
13
|
+
* from a cleanup worker that already selected an expired marker.
|
|
14
|
+
*/
|
|
8
15
|
export declare const OBJECT_STORAGE_PUBLICATION_SAFETY_MARGIN_MS: number;
|
|
9
16
|
export declare const OBJECT_STORAGE_REFERENCE_GRACE_MS: number;
|
|
10
17
|
export interface PreparedObjectStorageUpload {
|
|
@@ -12,6 +19,10 @@ export interface PreparedObjectStorageUpload {
|
|
|
12
19
|
path: string;
|
|
13
20
|
deleteAfter: Date;
|
|
14
21
|
}
|
|
22
|
+
export interface ObjectStorageUploadPayload {
|
|
23
|
+
upload: PreparedObjectStorageUpload;
|
|
24
|
+
payload: Uint8Array;
|
|
25
|
+
}
|
|
15
26
|
/**
|
|
16
27
|
* Coordinates the MongoDB outbox used to make object-storage changes recoverable.
|
|
17
28
|
*
|
|
@@ -35,10 +46,24 @@ export declare class ObjectStorageLifecycle {
|
|
|
35
46
|
* Indicate that files will be uploaded to S3.
|
|
36
47
|
*
|
|
37
48
|
* These markers are expected to be removed using publishUploads(). If that does not happen within
|
|
38
|
-
* the grace period, the files will be deleted.
|
|
49
|
+
* the grace period, the files will be deleted. Registration must be majority
|
|
50
|
+
* acknowledged before any PUT starts: losing a marker on failover would lose
|
|
51
|
+
* the only cleanup obligation for an unpublished object. A failed/ambiguous
|
|
52
|
+
* insert must therefore prevent uploads, even if some markers were inserted.
|
|
39
53
|
*/
|
|
40
|
-
prepareUploads(paths: string[], now?: Date): Promise<PreparedObjectStorageUpload[]>;
|
|
54
|
+
prepareUploads(paths: string[], now?: Date, session?: mongo.ClientSession): Promise<PreparedObjectStorageUpload[]>;
|
|
41
55
|
canPublish(upload: PreparedObjectStorageUpload, now?: Date): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Upload a durably registered generation, joining every started PUT on failure.
|
|
58
|
+
* The shared adapter limits concurrency; its queue must observe the same signal
|
|
59
|
+
* as an active request so no queued PUT can start after the protection deadline.
|
|
60
|
+
*
|
|
61
|
+
* Failed/ambiguous PUTs retain their original markers. S3's bounded request
|
|
62
|
+
* timeouts are far shorter than the one-hour orphan grace, including when a
|
|
63
|
+
* response is lost or the process dies. Cancellation does not prove an object
|
|
64
|
+
* is absent, so never delete an object or its marker on upload failure.
|
|
65
|
+
*/
|
|
66
|
+
storeUploads(uploads: ObjectStorageUploadPayload[], options?: ObjectStorageOperationOptions): Promise<void>;
|
|
42
67
|
/**
|
|
43
68
|
* Remove markers for files that have finished uploading, and are now referenced from other documents.
|
|
44
69
|
*
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import * as bson from 'bson';
|
|
2
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
3
|
+
import { REPLICATION_WRITE_OPTIONS } from '../../MongoReplicationOptions.js';
|
|
3
4
|
import { BucketDataObjectStorage } from './BucketDataObjectStorage.js';
|
|
4
5
|
export const OBJECT_STORAGE_UPLOAD_LEASE_MS = 60 * 60 * 1000;
|
|
6
|
+
/**
|
|
7
|
+
* Leave time for the bounded publication transaction and clock skew before
|
|
8
|
+
* cleanup can select a marker. Publication must finish within this margin after
|
|
9
|
+
* its eligibility check; checked marker deletion alone cannot protect an object
|
|
10
|
+
* from a cleanup worker that already selected an expired marker.
|
|
11
|
+
*/
|
|
5
12
|
export const OBJECT_STORAGE_PUBLICATION_SAFETY_MARGIN_MS = 2 * 60 * 1000;
|
|
6
13
|
export const OBJECT_STORAGE_REFERENCE_GRACE_MS = 15 * 60 * 1000;
|
|
7
14
|
/**
|
|
@@ -50,23 +57,71 @@ export class ObjectStorageLifecycle {
|
|
|
50
57
|
* Indicate that files will be uploaded to S3.
|
|
51
58
|
*
|
|
52
59
|
* These markers are expected to be removed using publishUploads(). If that does not happen within
|
|
53
|
-
* the grace period, the files will be deleted.
|
|
60
|
+
* the grace period, the files will be deleted. Registration must be majority
|
|
61
|
+
* acknowledged before any PUT starts: losing a marker on failover would lose
|
|
62
|
+
* the only cleanup obligation for an unpublished object. A failed/ambiguous
|
|
63
|
+
* insert must therefore prevent uploads, even if some markers were inserted.
|
|
54
64
|
*/
|
|
55
|
-
async prepareUploads(paths, now = new Date()) {
|
|
65
|
+
async prepareUploads(paths, now = new Date(), session) {
|
|
56
66
|
const deleteAfter = new Date(now.getTime() + OBJECT_STORAGE_UPLOAD_LEASE_MS);
|
|
57
67
|
const uploads = paths.map((path) => ({ markerId: new bson.ObjectId(), path, deleteAfter }));
|
|
58
|
-
if (uploads.length) {
|
|
68
|
+
if (uploads.length > 0) {
|
|
59
69
|
await this.db.pendingObjectStorageDeletes(this.replicationStreamId).insertMany(uploads.map((upload) => ({
|
|
60
70
|
_id: upload.markerId,
|
|
61
71
|
path: upload.path,
|
|
62
72
|
delete_after: upload.deleteAfter
|
|
63
|
-
})));
|
|
73
|
+
})), { ...REPLICATION_WRITE_OPTIONS, session });
|
|
64
74
|
}
|
|
65
75
|
return uploads;
|
|
66
76
|
}
|
|
67
77
|
canPublish(upload, now = new Date()) {
|
|
68
78
|
return now.getTime() < upload.deleteAfter.getTime() - OBJECT_STORAGE_PUBLICATION_SAFETY_MARGIN_MS;
|
|
69
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Upload a durably registered generation, joining every started PUT on failure.
|
|
82
|
+
* The shared adapter limits concurrency; its queue must observe the same signal
|
|
83
|
+
* as an active request so no queued PUT can start after the protection deadline.
|
|
84
|
+
*
|
|
85
|
+
* Failed/ambiguous PUTs retain their original markers. S3's bounded request
|
|
86
|
+
* timeouts are far shorter than the one-hour orphan grace, including when a
|
|
87
|
+
* response is lost or the process dies. Cancellation does not prove an object
|
|
88
|
+
* is absent, so never delete an object or its marker on upload failure.
|
|
89
|
+
*/
|
|
90
|
+
async storeUploads(uploads, options) {
|
|
91
|
+
if (uploads.length === 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const deadline = Math.min(...uploads.map(({ upload }) => upload.deleteAfter.getTime())) -
|
|
95
|
+
OBJECT_STORAGE_PUBLICATION_SAFETY_MARGIN_MS;
|
|
96
|
+
const remaining = deadline - Date.now();
|
|
97
|
+
if (remaining <= 0) {
|
|
98
|
+
throw new Error('Object storage upload lease expired before PUT');
|
|
99
|
+
}
|
|
100
|
+
const expiration = new AbortController();
|
|
101
|
+
const timer = setTimeout(() => expiration.abort(new Error('Object storage upload lease expired during PUT')), remaining);
|
|
102
|
+
timer.unref();
|
|
103
|
+
const signal = options?.signal ? AbortSignal.any([options.signal, expiration.signal]) : expiration.signal;
|
|
104
|
+
let results;
|
|
105
|
+
try {
|
|
106
|
+
results = await Promise.allSettled(uploads.map(async ({ upload, payload }) => {
|
|
107
|
+
signal.throwIfAborted();
|
|
108
|
+
// The timer handles time in the adapter's queue; this check also catches
|
|
109
|
+
// wall-clock changes before dispatch. Publication checks again later.
|
|
110
|
+
if (!this.canPublish(upload)) {
|
|
111
|
+
throw new Error(`Object storage upload lease expired for ${upload.path}`);
|
|
112
|
+
}
|
|
113
|
+
await this.bucketData.storeSerialized(upload.path, payload, { signal });
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
}
|
|
119
|
+
const failure = results.find((result) => result.status === 'rejected');
|
|
120
|
+
if (failure?.status === 'rejected') {
|
|
121
|
+
throw failure.reason;
|
|
122
|
+
}
|
|
123
|
+
signal.throwIfAborted();
|
|
124
|
+
}
|
|
70
125
|
/**
|
|
71
126
|
* Remove markers for files that have finished uploading, and are now referenced from other documents.
|
|
72
127
|
*
|
|
@@ -82,8 +137,9 @@ export class ObjectStorageLifecycle {
|
|
|
82
137
|
return;
|
|
83
138
|
}
|
|
84
139
|
writes.deleteMany(this.db.pendingObjectStorageDeletes(this.replicationStreamId), { _id: { $in: uploads.map((upload) => upload.markerId) } }, (deletedCount) => {
|
|
85
|
-
if (deletedCount !== uploads.length)
|
|
140
|
+
if (deletedCount !== uploads.length) {
|
|
86
141
|
throw new Error('Missing object storage publication markers');
|
|
142
|
+
}
|
|
87
143
|
});
|
|
88
144
|
}
|
|
89
145
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectStorageLifecycle.js","sourceRoot":"","sources":["../../../../../src/storage/implementation/v3/object-storage/ObjectStorageLifecycle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ObjectStorageLifecycle.js","sourceRoot":"","sources":["../../../../../src/storage/implementation/v3/object-storage/ObjectStorageLifecycle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,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ACD,MAAM,QAAQ,GAAG,KAAK,CAAC;YACvB,KAAK,GAAG,EAAE,CAAC;YACX,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAC1B,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EACrC,EAAE,MAAM,EAAE,CACX,CAAC;gBACF,MAAM,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YACnF,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;oBACpB,kFAAkF;oBAClF,uFAAuF;oBACvF,4DAA4D;oBAC5D,MAAM,KAAK,CAAC;gBACd,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,2FAA2F,EAAE,KAAK,CAAC,CAAC;YAClH,CAAC;QACH,CAAC,CAAC;QAEF,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;YAClC,MAAM,EAAE,cAAc,EAAE,CAAC;YACzB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACnB,IAAI,KAAK,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACzB,MAAM,WAAW,EAAE,CAAC;YACtB,CAAC;QACH,CAAC;QACD,MAAM,WAAW,EAAE,CAAC;IACtB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync/service-module-mongodb-storage",
|
|
3
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"license": "
|
|
4
|
+
"version": "0.24.0",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
@@ -17,19 +17,18 @@
|
|
|
17
17
|
"@smithy/node-http-handler": "^4.11.3",
|
|
18
18
|
"async-mutex": "^0.5.0",
|
|
19
19
|
"bson": "^6.10.4",
|
|
20
|
-
"ix": "^5.0.0",
|
|
21
20
|
"lru-cache": "^10.2.2",
|
|
22
21
|
"ts-codec": "^1.3.0",
|
|
23
22
|
"uuid": "^14.0.0",
|
|
24
|
-
"@powersync/lib-service-mongodb": "0.6.
|
|
25
|
-
"@powersync/lib-services-framework": "0.10.
|
|
26
|
-
"@powersync/service-core": "1.
|
|
27
|
-
"@powersync/service-jsonbig": "0.17.
|
|
28
|
-
"@powersync/service-sync-rules": "0.
|
|
29
|
-
"@powersync/service-types": "0.
|
|
23
|
+
"@powersync/lib-service-mongodb": "0.6.35",
|
|
24
|
+
"@powersync/lib-services-framework": "0.10.5",
|
|
25
|
+
"@powersync/service-core": "1.28.0",
|
|
26
|
+
"@powersync/service-jsonbig": "0.17.14",
|
|
27
|
+
"@powersync/service-sync-rules": "0.45.0",
|
|
28
|
+
"@powersync/service-types": "0.21.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
|
-
"@powersync/service-core-tests": "0.18.
|
|
31
|
+
"@powersync/service-core-tests": "0.18.5"
|
|
33
32
|
},
|
|
34
33
|
"scripts": {
|
|
35
34
|
"build": "tsc -b",
|
|
@@ -652,6 +652,10 @@ export class MongoBucketStorage extends storage.BucketStorageFactory {
|
|
|
652
652
|
*
|
|
653
653
|
* Use in the same transaction that the replacement stream is created.
|
|
654
654
|
*/
|
|
655
|
+
async stopProcessingSyncConfigs(): Promise<void> {
|
|
656
|
+
await this.withTransaction((session) => this.stopExistingProcessingWork(session));
|
|
657
|
+
}
|
|
658
|
+
|
|
655
659
|
private async stopExistingProcessingWork(session: mongo.ClientSession) {
|
|
656
660
|
await this.db.sync_rules.updateMany(
|
|
657
661
|
{
|