Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

v0.60.196.0 test(lock-order): retry a topology change that ran out of lock wait with its request_id (#6586)

garrytan9d2f84f241d4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b28593a159..df600ad79d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,18 @@ credits are retained; no result has been reassigned to another provider. Origina
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
+## [0.60.196.0] - 2026-10-13
+
+**The lock-order race test retries a topology change that ran out of lock wait, as the product tells callers to, so a single lock timeout on a loaded runner no longer fails it (#6586).** `test/e2e/persistence-publish-lock-order-postgres.test.ts` checks that ordinary writes racing claims and topology changes never form a lock-wait cycle and never deadlock. Each topology change runs with the production 1 s `lock_timeout`. When that wait runs out, the change ends `write_pending` with "Retry the same lifecycle request_id after the current writer finishes". The race recorded that as a failure. On #6591's gate-ahead run it did, once: one topology step hit 55P03 on a loaded gate VM with `cycles: []` and `deadlocks: 0`. The rerun on the same head passed, and 60 local runs with four CPU burners passed.
+
+### Itemized changes
+
+- **The race retries a lone timeout and keeps everything else strict.** Each topology step now has a fixed `request_id`. A step that ends `write_pending` right after its own 55P03 is retried with that same `request_id`, up to three attempts. That's what the error tells a caller to do, and it matches how the file already treats writer lock timeouts. The test still requires no lock-wait cycle in its `pg_blocking_pids` sampling, no deadlock in `pg_stat_database`, no write error, and every topology change committed. The retry count appears in the `[lock-order race]` line as `topologyRetries`.
+- **Forced probes (scratch copies, not committed):**
+ - A lone lock timeout with no inversion: a separate session holds the `persistence_brain` row for 1.5 s just before one topology step. The old test fails on `write_pending`, plus two `not_found` steps that followed it. The new test passes with `topologyRetries: 1`.
+ - A real inversion: two sessions take `persistence_brain` and `sources` in opposite orders during the race. Both the old and the new test fail on it, through the sampled cycle on the old file and `deadlocks: 2` on the new one.
+ - With four CPU burners on a 4-CPU machine, the whole file passed 10 of 10 runs on Bun 1.4.3.
+
## [0.60.195.0] - 2026-10-13
**CI and the release build move to Bun 1.4.3, which carries the fix for the spawnSync hang that poisoned whole test shards (#6586).** On Bun 1.4.0 to 1.4.2, a garbage-collection finalizer that runs while `Bun.spawnSync` waits can leave the runtime's private spawnSync loop miscounted for the rest of the process (oven-sh/bun#34069). After that, a synchronous child spawn may never notice its child exit. A spawn with a timeout comes back `ETIMEDOUT` even though the child finished, and one without a timeout spins until the test deadline kills it. Run 38335527492 hit this twice: `test (2)` hung in `test/managed-sync-pinned-reads.test.ts` and was cancelled, while the identical code on the identical file order passed on master and on #6576. Bun 1.4.3 (released 2026-10-10) contains upstream commit 13a98b0. `compare/bun-v1.4.3...13a98b0` reports `behind`, which means the release already has the commit. The supported install floor stays at Bun 1.4.0.
diff --git a/VERSION b/VERSION
index 915eeb6b91..c769a08a69 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.60.195.0
+0.60.196.0
diff --git a/test/e2e/persistence-publish-lock-order-postgres.test.ts b/test/e2e/persistence-publish-lock-order-postgres.test.ts
index 5d577619f0..0269d9cad2 100644
--- a/test/e2e/persistence-publish-lock-order-postgres.test.ts
+++ b/test/e2e/persistence-publish-lock-order-postgres.test.ts
@@ -20,7 +20,11 @@
* requires no such cycle, no deadlock (40P01), and every write and change
* committed, at the production 1 s `lock_timeout`. Lock timeouts (55P03) are
* logged, not failed: a starved runner can hold a lock past 1 s without any
- * inversion, and the writer retries.
+ * inversion, and the writer retries. A topology change whose bounded wait ran
+ * out ends `write_pending` ("retry the same lifecycle request_id"), so the race
+ * retries it with the same request_id, as a caller does, and only after its own
+ * 55P03 (#6586: one such lone timeout on a loaded gate VM failed the race with
+ * no cycle and no deadlock).
*/
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
import { AsyncLocalStorage } from 'node:async_hooks';
@@ -169,17 +173,25 @@ describeE2E('publication lock order vs brain-row administration (Postgres)', ()
}
})();
const topologyResults: string[] = [];
+ let topologyRetries = 0;
const topology = (async () => {
for (let i = 0; !stop && i < 12; i++) {
const dir = join(root, '..', `race-${i}`); mkdirSync(dir);
- const steps: Array<() => Promise<unknown>> = [
- () => runManagedSourceLifecycle(engine, { operation: 'add', sourceId: `race-${i}` }),
- () => runManagedSourceLifecycle(engine, { operation: 'claim', sourceId: `race-${i}`, path: dir }),
- () => runManagedSourceLifecycle(engine, { operation: 'archive', sourceId: `race-${i}` }),
+ const steps: Array<(requestId: string) => Promise<unknown>> = [
+ requestId => runManagedSourceLifecycle(engine, { operation: 'add', sourceId: `race-${i}`, requestId }),
+ requestId => runManagedSourceLifecycle(engine, { operation: 'claim', sourceId: `race-${i}`, path: dir, requestId }),
+ requestId => runManagedSourceLifecycle(engine, { operation: 'archive', sourceId: `race-${i}`, requestId }),
];
for (const step of steps) {
- const result = await settle(scope.run({ label: 'topology' }, step));
- topologyResults.push(result.ok ? 'committed' : String((result.error as { code?: string }).code ?? result.error.message));
+ const requestId = randomUUID();
+ for (let attempt = 1; ; attempt++) {
+ const timeoutsBefore = failures['topology:55P03'] ?? 0;
+ const result = await settle(scope.run({ label: 'topology' }, () => step(requestId)));
+ const code = result.ok ? 'committed' : String((result.error as { code?: string }).code ?? result.error.message);
+ if (code === 'write_pending' && (failures['topology:55P03'] ?? 0) > timeoutsBefore && attempt < 3) { topologyRetries++; continue; }
+ topologyResults.push(code);
+ break;
+ }
}
}
})();
@@ -196,7 +208,7 @@ describeE2E('publication lock order vs brain-row administration (Postgres)', ()
const results = await Promise.all(writes);
const observed = {
writes: results.length, writeErrors: results.filter(r => r.isError).map(r => /"code": "([a-z_]+)"/.exec(r.text)?.[1] ?? r.text.slice(0, 160)),
- topology: topologyResults.reduce<Record<string, number>>((acc, r) => ({ ...acc, [r]: (acc[r] ?? 0) + 1 }), {}),
+ topology: topologyResults.reduce<Record<string, number>>((acc, r) => ({ ...acc, [r]: (acc[r] ?? 0) + 1 }), {}), topologyRetries,
deadlocks: await deadlocks(monitor, engine) - before, lockTimeouts: { ...failures }, cycles: [...cycles],
};
console.log('[lock-order race]', JSON.stringify(observed));