@powersync/service-module-mongodb-storage 0.0.0-dev-20260114171046 → 0.0.0-dev-20260115105618
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 +7 -5
- package/dist/storage/implementation/MongoSyncRulesLock.d.ts +0 -1
- package/dist/storage/implementation/MongoSyncRulesLock.js +3 -15
- package/dist/storage/implementation/MongoSyncRulesLock.js.map +1 -1
- package/package.json +6 -6
- package/src/storage/implementation/MongoSyncRulesLock.ts +9 -19
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @powersync/service-module-mongodb-storage
|
|
2
2
|
|
|
3
|
-
## 0.0.0-dev-
|
|
3
|
+
## 0.0.0-dev-20260115105618
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -8,13 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
|
+
- 0255483: Reduced log output for waiting replication pod
|
|
11
12
|
- Updated dependencies [781d0e3]
|
|
12
13
|
- Updated dependencies [e578245]
|
|
13
14
|
- Updated dependencies [3040079]
|
|
14
|
-
|
|
15
|
-
- @powersync/service-
|
|
16
|
-
- @powersync/
|
|
17
|
-
- @powersync/lib-
|
|
15
|
+
- Updated dependencies [0255483]
|
|
16
|
+
- @powersync/service-core@0.0.0-dev-20260115105618
|
|
17
|
+
- @powersync/service-sync-rules@0.0.0-dev-20260115105618
|
|
18
|
+
- @powersync/lib-services-framework@0.0.0-dev-20260115105618
|
|
19
|
+
- @powersync/lib-service-mongodb@0.0.0-dev-20260115105618
|
|
18
20
|
|
|
19
21
|
## 0.12.16
|
|
20
22
|
|
|
@@ -9,7 +9,6 @@ export declare class MongoSyncRulesLock implements storage.ReplicationLock {
|
|
|
9
9
|
sync_rules_id: number;
|
|
10
10
|
private lock_id;
|
|
11
11
|
private readonly refreshInterval;
|
|
12
|
-
private static lockAlerted;
|
|
13
12
|
static createLock(db: PowerSyncMongo, sync_rules: storage.PersistedSyncRulesContent): Promise<MongoSyncRulesLock>;
|
|
14
13
|
constructor(db: PowerSyncMongo, sync_rules_id: number, lock_id: string);
|
|
15
14
|
release(): Promise<void>;
|
|
@@ -9,7 +9,6 @@ export class MongoSyncRulesLock {
|
|
|
9
9
|
sync_rules_id;
|
|
10
10
|
lock_id;
|
|
11
11
|
refreshInterval;
|
|
12
|
-
static lockAlerted = false;
|
|
13
12
|
static async createLock(db, sync_rules) {
|
|
14
13
|
const lockId = crypto.randomBytes(8).toString('hex');
|
|
15
14
|
const doc = await db.sync_rules.findOneAndUpdate({ _id: sync_rules.id, $or: [{ lock: null }, { 'lock.expires_at': { $lt: new Date() } }] }, {
|
|
@@ -27,24 +26,13 @@ export class MongoSyncRulesLock {
|
|
|
27
26
|
// Query the existing lock to get the expiration time (best effort - it may have been released in the meantime).
|
|
28
27
|
const heldLock = await db.sync_rules.findOne({ _id: sync_rules.id }, { projection: { lock: 1 } });
|
|
29
28
|
if (heldLock?.lock?.expires_at) {
|
|
30
|
-
|
|
31
|
-
this.lockAlerted = true;
|
|
32
|
-
throw new ServiceError(ErrorCode.PSYNC_S1003, `Sync rules: ${sync_rules.id} have been locked by another process for replication, expiring at ${heldLock.lock.expires_at.toISOString()}.`);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
throw undefined;
|
|
36
|
-
}
|
|
29
|
+
throw new ServiceError(ErrorCode.PSYNC_S1003, `Sync rules: ${sync_rules.id} have been locked by another process for replication, expiring at ${heldLock.lock.expires_at.toISOString()}.`);
|
|
37
30
|
}
|
|
38
31
|
else {
|
|
39
|
-
|
|
40
|
-
throw new ServiceError(ErrorCode.PSYNC_S1003, `Sync rules: ${sync_rules.id} have been locked by another process for replication.`);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
throw undefined;
|
|
44
|
-
}
|
|
32
|
+
throw new ServiceError(ErrorCode.PSYNC_S1003, `Sync rules: ${sync_rules.id} have been locked by another process for replication.`);
|
|
45
33
|
}
|
|
46
34
|
}
|
|
47
|
-
|
|
35
|
+
logger.info(`Sync rules: ${sync_rules.id} has been locked for replication with lock ID ${lockId}.`);
|
|
48
36
|
return new MongoSyncRulesLock(db, sync_rules.id, lockId);
|
|
49
37
|
}
|
|
50
38
|
constructor(db, sync_rules_id, lock_id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoSyncRulesLock.js","sourceRoot":"","sources":["../../../src/storage/implementation/MongoSyncRulesLock.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAIpF;;;GAGG;AACH,MAAM,OAAO,kBAAkB;
|
|
1
|
+
{"version":3,"file":"MongoSyncRulesLock.js","sourceRoot":"","sources":["../../../src/storage/implementation/MongoSyncRulesLock.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAIpF;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IA4CnB;IACD;IACC;IA7CO,eAAe,CAAiB;IAEjD,MAAM,CAAC,KAAK,CAAC,UAAU,CACrB,EAAkB,EAClB,UAA6C;QAE7C,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrD,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAC9C,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,EAAE,EAAE,GAAG,EAAE,IAAI,IAAI,EAAE,EAAE,EAAE,CA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CAAC,aAAa,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@powersync/service-module-mongodb-storage",
|
|
3
3
|
"repository": "https://github.com/powersync-ja/powersync-service",
|
|
4
4
|
"types": "dist/index.d.ts",
|
|
5
|
-
"version": "0.0.0-dev-
|
|
5
|
+
"version": "0.0.0-dev-20260115105618",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"license": "FSL-1.1-ALv2",
|
|
8
8
|
"type": "module",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
"lru-cache": "^10.2.2",
|
|
28
28
|
"ts-codec": "^1.3.0",
|
|
29
29
|
"uuid": "^11.1.0",
|
|
30
|
-
"@powersync/lib-service-mongodb": "0.0.0-dev-
|
|
31
|
-
"@powersync/lib-services-framework": "0.0.0-dev-
|
|
32
|
-
"@powersync/service-core": "0.0.0-dev-
|
|
30
|
+
"@powersync/lib-service-mongodb": "0.0.0-dev-20260115105618",
|
|
31
|
+
"@powersync/lib-services-framework": "0.0.0-dev-20260115105618",
|
|
32
|
+
"@powersync/service-core": "0.0.0-dev-20260115105618",
|
|
33
33
|
"@powersync/service-jsonbig": "0.17.12",
|
|
34
|
-
"@powersync/service-sync-rules": "0.0.0-dev-
|
|
34
|
+
"@powersync/service-sync-rules": "0.0.0-dev-20260115105618",
|
|
35
35
|
"@powersync/service-types": "0.13.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@powersync/service-core-tests": "0.0.0-dev-
|
|
38
|
+
"@powersync/service-core-tests": "0.0.0-dev-20260115105618"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsc -b",
|
|
@@ -10,7 +10,6 @@ import { PowerSyncMongo } from './db.js';
|
|
|
10
10
|
*/
|
|
11
11
|
export class MongoSyncRulesLock implements storage.ReplicationLock {
|
|
12
12
|
private readonly refreshInterval: NodeJS.Timeout;
|
|
13
|
-
private static lockAlerted: boolean = false;
|
|
14
13
|
|
|
15
14
|
static async createLock(
|
|
16
15
|
db: PowerSyncMongo,
|
|
@@ -37,27 +36,18 @@ export class MongoSyncRulesLock implements storage.ReplicationLock {
|
|
|
37
36
|
// Query the existing lock to get the expiration time (best effort - it may have been released in the meantime).
|
|
38
37
|
const heldLock = await db.sync_rules.findOne({ _id: sync_rules.id }, { projection: { lock: 1 } });
|
|
39
38
|
if (heldLock?.lock?.expires_at) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`Sync rules: ${sync_rules.id} have been locked by another process for replication, expiring at ${heldLock.lock.expires_at.toISOString()}.`
|
|
45
|
-
);
|
|
46
|
-
} else {
|
|
47
|
-
throw undefined;
|
|
48
|
-
}
|
|
39
|
+
throw new ServiceError(
|
|
40
|
+
ErrorCode.PSYNC_S1003,
|
|
41
|
+
`Sync rules: ${sync_rules.id} have been locked by another process for replication, expiring at ${heldLock.lock.expires_at.toISOString()}.`
|
|
42
|
+
);
|
|
49
43
|
} else {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
);
|
|
55
|
-
} else {
|
|
56
|
-
throw undefined;
|
|
57
|
-
}
|
|
44
|
+
throw new ServiceError(
|
|
45
|
+
ErrorCode.PSYNC_S1003,
|
|
46
|
+
`Sync rules: ${sync_rules.id} have been locked by another process for replication.`
|
|
47
|
+
);
|
|
58
48
|
}
|
|
59
49
|
}
|
|
60
|
-
|
|
50
|
+
logger.info(`Sync rules: ${sync_rules.id} has been locked for replication with lock ID ${lockId}.`);
|
|
61
51
|
return new MongoSyncRulesLock(db, sync_rules.id, lockId);
|
|
62
52
|
}
|
|
63
53
|
|