@syncular/server 0.30.3 → 0.30.4

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.
@@ -1010,6 +1010,17 @@ FOR EACH ROW EXECUTE FUNCTION syncular_writer_fence()`);
1010
1010
  await client.query(`INSERT INTO sync_schema_meta(id, schema_version, layouts) VALUES (1, $1, $2)
1011
1011
  ON CONFLICT (id) DO UPDATE
1012
1012
  SET schema_version=EXCLUDED.schema_version, layouts=EXCLUDED.layouts`, [schema.version, layoutsOf(schema)]);
1013
+ // A writer of the previous schema still running against this
1014
+ // database would append payloads in the previous layout. Its push
1015
+ // is refused by the serve gate, but a host's server-side
1016
+ // `begin()`/`appendCommit` reads no gate, so the bump raises the
1017
+ // writer fence of every partition to the new version.
1018
+ await client.query(`INSERT INTO sync_writer_fence(partition, required_writer_version)
1019
+ SELECT partition, $1 FROM sync_partitions
1020
+ ON CONFLICT (partition) DO UPDATE SET
1021
+ required_writer_version=GREATEST(
1022
+ sync_writer_fence.required_writer_version,
1023
+ EXCLUDED.required_writer_version)`, [schema.version]);
1013
1024
  // The host's declared checkpoints install in the schema-bump
1014
1025
  // transaction, so no observer sees the bumped marker without the
1015
1026
  // fence, or the fence without its declaration row.
@@ -412,6 +412,17 @@ END`);
412
412
  this.db
413
413
  .query('INSERT INTO sync_schema_meta(id, schema_version, layouts) VALUES (1, ?, ?) ON CONFLICT(id) DO UPDATE SET schema_version=excluded.schema_version, layouts=excluded.layouts')
414
414
  .run(schema.version, layoutsOf(schema));
415
+ // A writer of the previous schema would append payloads in the
416
+ // previous layout; the bump fences every partition at the new
417
+ // version (see PostgresServerStorage.ensureSchema).
418
+ this.db
419
+ .query(`INSERT INTO sync_writer_fence(partition, required_writer_version)
420
+ SELECT partition, ? FROM sync_partitions WHERE true
421
+ ON CONFLICT(partition) DO UPDATE SET
422
+ required_writer_version=max(
423
+ sync_writer_fence.required_writer_version,
424
+ excluded.required_writer_version)`)
425
+ .run(schema.version);
415
426
  // The host's declared checkpoints install in the schema-bump
416
427
  // transaction, so no observer sees the bumped marker without the
417
428
  // fence, or the fence without its declaration row.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncular/server",
3
- "version": "0.30.3",
3
+ "version": "0.30.4",
4
4
  "description": "Syncular server: handleSyncRequest + storage/auth interfaces for the sync protocol",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Benjamin Kniffler",
@@ -68,7 +68,7 @@
68
68
  "verify:node": "cd ../.. && bun build ./packages/server/test/sqlite-runtime/verify-node.mjs --target=node --conditions=bun --outfile=./packages/server/.verify-node.built.mjs && node ./packages/server/.verify-node.built.mjs"
69
69
  },
70
70
  "dependencies": {
71
- "@syncular/core": "0.30.3"
71
+ "@syncular/core": "0.30.4"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@electric-sql/pglite": "^0.5.4"
@@ -1558,6 +1558,20 @@ FOR EACH ROW EXECUTE FUNCTION syncular_writer_fence()`);
1558
1558
  SET schema_version=EXCLUDED.schema_version, layouts=EXCLUDED.layouts`,
1559
1559
  [schema.version, layoutsOf(schema)],
1560
1560
  );
1561
+ // A writer of the previous schema still running against this
1562
+ // database would append payloads in the previous layout. Its push
1563
+ // is refused by the serve gate, but a host's server-side
1564
+ // `begin()`/`appendCommit` reads no gate, so the bump raises the
1565
+ // writer fence of every partition to the new version.
1566
+ await client.query(
1567
+ `INSERT INTO sync_writer_fence(partition, required_writer_version)
1568
+ SELECT partition, $1 FROM sync_partitions
1569
+ ON CONFLICT (partition) DO UPDATE SET
1570
+ required_writer_version=GREATEST(
1571
+ sync_writer_fence.required_writer_version,
1572
+ EXCLUDED.required_writer_version)`,
1573
+ [schema.version],
1574
+ );
1561
1575
  // The host's declared checkpoints install in the schema-bump
1562
1576
  // transaction, so no observer sees the bumped marker without the
1563
1577
  // fence, or the fence without its declaration row.
@@ -698,6 +698,19 @@ END`);
698
698
  'INSERT INTO sync_schema_meta(id, schema_version, layouts) VALUES (1, ?, ?) ON CONFLICT(id) DO UPDATE SET schema_version=excluded.schema_version, layouts=excluded.layouts',
699
699
  )
700
700
  .run(schema.version, layoutsOf(schema));
701
+ // A writer of the previous schema would append payloads in the
702
+ // previous layout; the bump fences every partition at the new
703
+ // version (see PostgresServerStorage.ensureSchema).
704
+ this.db
705
+ .query(
706
+ `INSERT INTO sync_writer_fence(partition, required_writer_version)
707
+ SELECT partition, ? FROM sync_partitions WHERE true
708
+ ON CONFLICT(partition) DO UPDATE SET
709
+ required_writer_version=max(
710
+ sync_writer_fence.required_writer_version,
711
+ excluded.required_writer_version)`,
712
+ )
713
+ .run(schema.version);
701
714
  // The host's declared checkpoints install in the schema-bump
702
715
  // transaction, so no observer sees the bumped marker without the
703
716
  // fence, or the fence without its declaration row.