Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

persistence: a charged member publishes as a group of one; deadline-group e2e waits out the charged backoff

garrytan09ea7c1ae5a3
diff --git a/src/core/persistence/consumer.ts b/src/core/persistence/consumer.ts
index c97871cb99..bc82a3ae38 100644
--- a/src/core/persistence/consumer.ts
+++ b/src/core/persistence/consumer.ts
@@ -1070,8 +1070,9 @@ export class PersistenceConsumer implements PersistenceConsumerLike {
// A managed import batch also groups on PGLite: its members share one transaction's guards there too.
if (!group || this.engine.kind !== 'postgres' && !group.startsWith('import:')) return this.execute(row, root);
// #6007: a put_pages or import batch publishes in groups of at most PAGE_BATCH_GROUP_MAX pages.
- const followers = (row.transient_interruptions ?? 0) > 0 ? [] : await claimGroupFollowers(this.engine, row, group, syncGroup(group) ? 63 : PAGE_BATCH_GROUP_MAX - 1);
- if (!followers.length && !lane) return this.execute(row, root);
+ const charged = (row.transient_interruptions ?? 0) > 0;
+ const followers = charged ? [] : await claimGroupFollowers(this.engine, row, group, syncGroup(group) ? 63 : PAGE_BATCH_GROUP_MAX - 1);
+ if (!followers.length && !lane && !charged) return this.execute(row, root);
claimed.push(...followers);
const rows = [row, ...followers];
for (const member of rows) this.executing.add(member.id);
diff --git a/test/e2e/publication-deadline-group-postgres.test.ts b/test/e2e/publication-deadline-group-postgres.test.ts
index 67d9e8fd3b..d2dbde5749 100644
--- a/test/e2e/publication-deadline-group-postgres.test.ts
+++ b/test/e2e/publication-deadline-group-postgres.test.ts
@@ -104,10 +104,16 @@ d('publication deadline on a grouped publish (Postgres)', () => {
// Restoration ran after the parked body settled: the original bytes were back before any retry.
expect(rolledBackBytes).toBe(original);
- // Whatever the group left queued, the ordinary route publishes it.
- for (let i = 0; i < 10; i++) {
+ // The cancelled publication was charged to each member as a transient interruption, which schedules its next claim.
+ expect((await batchRows()).map(row => row.transient_interruptions)).toEqual([1, 1, 1]);
+ // Whatever the group left queued, the ordinary route publishes it once that backoff has passed.
+ for (let i = 0; i < 100; i++) {
const next = await claimNextWrite(engine, localHostId());
- if (!next) break;
+ if (!next) {
+ if (!(await batchRows()).some(row => row.state === 'queued')) break;
+ await tick(100);
+ continue;
+ }
const more = publicationGroupKey(next) ? await claimGroupFollowers(engine, next, publicationGroupKey(next)!, 7) : [];
await executeClaimedGroup(engine, [next, ...more], { hostId: localHostId(), prepare: async row => preparePersistedMutation(engine, row, config as never), settled: row => settled.push(row) });
}