Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(persistence): migration v221 persistence_consumers heartbeat table and committed-receipt watermark index (#6317 T-01)
garrytan4bea9000b6ae
diff --git a/src/core/persistence/schema.ts b/src/core/persistence/schema.tsindex e4c94b8106..d3ed61e32a 100644--- a/src/core/persistence/schema.ts+++ b/src/core/persistence/schema.ts@@ -18,9 +18,46 @@ export const PERSISTENCE_SYNC_RUN_INDEXES = [{ name: 'persistence_requests_sync_run_open', sql: PERSISTENCE_SYNC_RUN_OPEN_INDEX_SQL },{ name: 'persistence_requests_sync_run_committed', sql: PERSISTENCE_SYNC_RUN_COMMITTED_INDEX_SQL },] as const;+/**+ * #6317: the movement watermark (the newest committed receipt of a worktree)+ * that `writer movement`, `data_moving` and doctor `managed_sync_not_moving`+ * read; the baseline indexes cover pending, recovery and principal reads+ * only. Postgres builds it CONCURRENTLY in migration v221; PGLite inline.+ */+export const PERSISTENCE_COMMITTED_WATERMARK_INDEX_SQL = `CREATE INDEX IF NOT EXISTS persistence_requests_committed_watermark+ ON persistence_requests(worktree_id,completed_at DESC) WHERE state='committed'`;+export const PERSISTENCE_COMMITTED_WATERMARK_INDEX = { name: 'persistence_requests_committed_watermark', table: 'persistence_requests', sql: PERSISTENCE_COMMITTED_WATERMARK_INDEX_SQL } as const;+/**+ * #6317: one row per process that runs a full persistence consumer on a host+ * (consumer-heartbeat.ts). The primary key carries the process nonce, so a+ * reused pid after a container restart is a new row; `pid_ns` tells pid+ * namespaces apart. `renewed_at` is the liveness signal (live within 30 s,+ * lapsed at 60 s, purged by a renewal after 90 s); `restart_required` and+ * `root_barrier_age_ms` are the owner's own wedge report; `host_json_path`,+ * `persistence_home` and `minted_under` let doctor name the owner's identity+ * file without reading its filesystem.+ */+export const PERSISTENCE_CONSUMERS_TABLE_SQL = `CREATE TABLE IF NOT EXISTS persistence_consumers (+ host_id uuid NOT NULL,+ pid integer NOT NULL,+ nonce text NOT NULL,+ pid_ns text,+ kind text NOT NULL,+ mode text NOT NULL CHECK (mode IN ('probing','full','waiter_only','promoted')),+ started_at timestamptz NOT NULL DEFAULT now(),+ renewed_at timestamptz NOT NULL DEFAULT now(),+ restart_required boolean NOT NULL DEFAULT false,+ root_barrier_age_ms integer,+ pool jsonb,+ host_json_path text NOT NULL,+ persistence_home text NOT NULL,+ minted_under jsonb,+ version text NOT NULL,+ PRIMARY KEY(host_id,pid,nonce)+ )`;/** Indexes the Postgres blob omits because a migration builds them CONCURRENTLY. */export const POSTGRES_CONCURRENT_PERSISTENCE_INDEXES: ReadonlySet<string> = new Set([- PERSISTENCE_DATABASE_PENDING_INDEX_SQL, PERSISTENCE_SYNC_RUN_OPEN_INDEX_SQL, PERSISTENCE_SYNC_RUN_COMMITTED_INDEX_SQL,+ PERSISTENCE_DATABASE_PENDING_INDEX_SQL, PERSISTENCE_SYNC_RUN_OPEN_INDEX_SQL, PERSISTENCE_SYNC_RUN_COMMITTED_INDEX_SQL, PERSISTENCE_COMMITTED_WATERMARK_INDEX_SQL,]);/** Durable infrastructure: never reconstruct or discard these rows during page reindexing. */export const PERSISTENCE_SCHEMA_STATEMENTS = [@@ -111,6 +148,7 @@ export const PERSISTENCE_SCHEMA_STATEMENTS = [PERSISTENCE_DATABASE_PENDING_INDEX_SQL,PERSISTENCE_SYNC_RUN_OPEN_INDEX_SQL,PERSISTENCE_SYNC_RUN_COMMITTED_INDEX_SQL,+ PERSISTENCE_COMMITTED_WATERMARK_INDEX_SQL,`CREATE INDEX IF NOT EXISTS persistence_requests_principal ON persistence_requests(principal_kind,principal_id,sequence DESC)`,`CREATE TABLE IF NOT EXISTS persistence_effects (id bigserial PRIMARY KEY,@@ -123,5 +161,6 @@ export const PERSISTENCE_SCHEMA_STATEMENTS = [updated_at timestamptz NOT NULL DEFAULT now(),UNIQUE(request_id,kind))`,+ PERSISTENCE_CONSUMERS_TABLE_SQL,MANAGED_WRITER_GUARD_SQL,] as const;diff --git a/src/core/pglite-schema.generated.ts b/src/core/pglite-schema.generated.tsindex d2c8054a97..452e5e49d2 100644--- a/src/core/pglite-schema.generated.ts+++ b/src/core/pglite-schema.generated.ts@@ -1307,6 +1307,8 @@ CREATE INDEX IF NOT EXISTS persistence_requests_sync_run_openON persistence_requests(worktree_id,(intent->>'runId')) WHERE state<>'committed' AND intent->>'kind' IN ('managed_sync_import','managed_sync_delete');CREATE INDEX IF NOT EXISTS persistence_requests_sync_run_committedON persistence_requests(source_id,(intent->>'runId'),(intent->>'index')) WHERE state='committed' AND intent ? 'runId';+CREATE INDEX IF NOT EXISTS persistence_requests_committed_watermark+ ON persistence_requests(worktree_id,completed_at DESC) WHERE state='committed';CREATE INDEX IF NOT EXISTS persistence_requests_principal ON persistence_requests(principal_kind,principal_id,sequence DESC);CREATE TABLE IF NOT EXISTS persistence_effects (id bigserial PRIMARY KEY,@@ -1319,6 +1321,24 @@ CREATE TABLE IF NOT EXISTS persistence_effects (updated_at timestamptz NOT NULL DEFAULT now(),UNIQUE(request_id,kind));+CREATE TABLE IF NOT EXISTS persistence_consumers (+ host_id uuid NOT NULL,+ pid integer NOT NULL,+ nonce text NOT NULL,+ pid_ns text,+ kind text NOT NULL,+ mode text NOT NULL CHECK (mode IN ('probing','full','waiter_only','promoted')),+ started_at timestamptz NOT NULL DEFAULT now(),+ renewed_at timestamptz NOT NULL DEFAULT now(),+ restart_required boolean NOT NULL DEFAULT false,+ root_barrier_age_ms integer,+ pool jsonb,+ host_json_path text NOT NULL,+ persistence_home text NOT NULL,+ minted_under jsonb,+ version text NOT NULL,+ PRIMARY KEY(host_id,pid,nonce)+ );CREATE OR REPLACE FUNCTION gbrain_require_managed_writer() RETURNS trigger LANGUAGE plpgsql SET search_path = pg_catalog, public AS \$fn\$DECLARE target_source text; old_source text; row_data jsonb; old_data jsonb; allowed jsonb;diff --git a/src/core/schema-embedded.generated.ts b/src/core/schema-embedded.generated.tsindex 4566433c96..52b8bc3957 100644--- a/src/core/schema-embedded.generated.ts+++ b/src/core/schema-embedded.generated.ts@@ -2041,6 +2041,24 @@ CREATE TABLE IF NOT EXISTS persistence_effects (updated_at timestamptz NOT NULL DEFAULT now(),UNIQUE(request_id,kind));+CREATE TABLE IF NOT EXISTS persistence_consumers (+ host_id uuid NOT NULL,+ pid integer NOT NULL,+ nonce text NOT NULL,+ pid_ns text,+ kind text NOT NULL,+ mode text NOT NULL CHECK (mode IN ('probing','full','waiter_only','promoted')),+ started_at timestamptz NOT NULL DEFAULT now(),+ renewed_at timestamptz NOT NULL DEFAULT now(),+ restart_required boolean NOT NULL DEFAULT false,+ root_barrier_age_ms integer,+ pool jsonb,+ host_json_path text NOT NULL,+ persistence_home text NOT NULL,+ minted_under jsonb,+ version text NOT NULL,+ PRIMARY KEY(host_id,pid,nonce)+ );CREATE OR REPLACE FUNCTION gbrain_require_managed_writer() RETURNS trigger LANGUAGE plpgsql SET search_path = pg_catalog, public AS \$fn\$DECLARE target_source text; old_source text; row_data jsonb; old_data jsonb; allowed jsonb;diff --git a/src/core/schema-migrations/registry.generated.ts b/src/core/schema-migrations/registry.generated.tsindex c693ecefee..f17e1875f2 100644--- a/src/core/schema-migrations/registry.generated.ts+++ b/src/core/schema-migrations/registry.generated.ts@@ -221,6 +221,7 @@ import { v217 } from './v217-persistence-request-claim-phase.ts';import { v218 } from './v218-purge-legacy-worktree-manifest-files.ts';import { v219 } from './v219-pages-reconcile-name-indexes.ts';import { v220 } from './v220-persistence-request-preparation-attempts.ts';+import { v221 } from './v221-persistence-consumers.ts';// Array order is historical (see HISTORICAL_ARRAY_ORDER in the generator); the// runner sorts by version before applying.@@ -440,4 +441,5 @@ export const MIGRATIONS: Migration[] = [v218,v219,v220,+ v221,];diff --git a/src/core/schema-migrations/v221-persistence-consumers.ts b/src/core/schema-migrations/v221-persistence-consumers.tsnew file mode 100644index 0000000000..2fb6296eec--- /dev/null+++ b/src/core/schema-migrations/v221-persistence-consumers.ts@@ -0,0 +1,25 @@+import type { Migration } from './types.ts';+import { PERSISTENCE_COMMITTED_WATERMARK_INDEX, PERSISTENCE_CONSUMERS_TABLE_SQL } from '../persistence/schema.ts';+import { buildIndexOnline, migrationNotice } from './helpers.ts';++// Applied by src/core/migrate.ts on the next initSchema(); see docs/ENGINES.md+// ("Canonical schema sources") for when schema.sql or a TS fragment also changes.+//+// #6317: `persistence_consumers`, the per-process heartbeat of every full+// persistence consumer on a host (persistence/consumer-heartbeat.ts): a+// resident process defers to the first live full consumer of its host+// (`persistence.single_consumer`), doctor `two_consumers_on_host` names a+// persistent overlap and `writer status --json` lists `host.consumers`. The+// table also lives in `PERSISTENCE_SCHEMA_STATEMENTS` for fresh installs. The+// partial `(worktree_id, completed_at DESC) WHERE state='committed'` index is+// the movement watermark read; Postgres builds it CONCURRENTLY here (the blob+// omits it, like the #5762 sync-run indexes), PGLite inline.+export const v221: Migration = {+ version: 221,+ name: 'persistence_consumers',+ idempotent: true,+ sql: PERSISTENCE_CONSUMERS_TABLE_SQL,+ handler: async engine => {+ await buildIndexOnline(engine, 221, PERSISTENCE_COMMITTED_WATERMARK_INDEX, { notice: migrationNotice });+ },+};diff --git a/src/schema.sql b/src/schema.sqlindex aebd2e4791..e339f5735a 100644--- a/src/schema.sql+++ b/src/schema.sql@@ -2037,6 +2037,24 @@ CREATE TABLE IF NOT EXISTS persistence_effects (updated_at timestamptz NOT NULL DEFAULT now(),UNIQUE(request_id,kind));+CREATE TABLE IF NOT EXISTS persistence_consumers (+ host_id uuid NOT NULL,+ pid integer NOT NULL,+ nonce text NOT NULL,+ pid_ns text,+ kind text NOT NULL,+ mode text NOT NULL CHECK (mode IN ('probing','full','waiter_only','promoted')),+ started_at timestamptz NOT NULL DEFAULT now(),+ renewed_at timestamptz NOT NULL DEFAULT now(),+ restart_required boolean NOT NULL DEFAULT false,+ root_barrier_age_ms integer,+ pool jsonb,+ host_json_path text NOT NULL,+ persistence_home text NOT NULL,+ minted_under jsonb,+ version text NOT NULL,+ PRIMARY KEY(host_id,pid,nonce)+ );CREATE OR REPLACE FUNCTION gbrain_require_managed_writer() RETURNS trigger LANGUAGE plpgsql SET search_path = pg_catalog, public AS $fn$DECLARE target_source text; old_source text; row_data jsonb; old_data jsonb; allowed jsonb;diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-default.json b/test/fixtures/goldens/catalog/pglite-engine-init-default.jsonindex e8324ee525..16ff37544b 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-default.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-default.json@@ -207,6 +207,8 @@"persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",+ "persistence_consumers.persistence_consumers_mode_check": "c CHECK ((mode = ANY (ARRAY['probing'::text, 'full'::text, 'waiter_only'::text, 'promoted'::text])))",+ "persistence_consumers.persistence_consumers_pkey": "p PRIMARY KEY (host_id, pid, nonce)","persistence_counters.persistence_counters_intent_bytes_check": "c CHECK ((intent_bytes >= 0))","persistence_counters.persistence_counters_lifetime_ids_check": "c CHECK ((lifetime_ids >= 0))","persistence_counters.persistence_counters_outstanding_count_check": "c CHECK ((outstanding_count >= 0))",@@ -622,6 +624,9 @@"persistence_brain": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_consumers": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_counters": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -1033,6 +1038,7 @@"pages_source_path_name_idx": "CREATE INDEX pages_source_path_name_idx ON public.pages USING btree (source_id, regexp_replace(replace(btrim(source_path), chr(92), '/'::text), '^.*/'::text, ''::text)) WHERE (source_path IS NOT NULL)","pages_source_slug_key": "CREATE UNIQUE INDEX pages_source_slug_key ON public.pages USING btree (source_id, slug)","persistence_brain_pkey": "CREATE UNIQUE INDEX persistence_brain_pkey ON public.persistence_brain USING btree (singleton)",+ "persistence_consumers_pkey": "CREATE UNIQUE INDEX persistence_consumers_pkey ON public.persistence_consumers USING btree (host_id, pid, nonce)","persistence_counters_pkey": "CREATE UNIQUE INDEX persistence_counters_pkey ON public.persistence_counters USING btree (key)","persistence_effects_parked": "CREATE INDEX persistence_effects_parked ON public.persistence_effects USING btree (id) WHERE (data ? 'parked'::text)","persistence_effects_pending": "CREATE INDEX persistence_effects_pending ON public.persistence_effects USING btree (next_attempt_at, id) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text]))",@@ -1043,6 +1049,7 @@"persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",+ "persistence_requests_committed_watermark": "CREATE INDEX persistence_requests_committed_watermark ON public.persistence_requests USING btree (worktree_id, completed_at DESC) WHERE (state = 'committed'::text)","persistence_requests_database_pending": "CREATE INDEX persistence_requests_database_pending ON public.persistence_requests USING btree (source_incarnation, sequence) WHERE ((worktree_id IS NULL) AND (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text])))","persistence_requests_pending": "CREATE INDEX persistence_requests_pending ON public.persistence_requests USING btree (worktree_id, sequence) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text]))","persistence_requests_pkey": "CREATE UNIQUE INDEX persistence_requests_pkey ON public.persistence_requests USING btree (id)",@@ -2451,6 +2458,26 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_consumers": {+ "columns": [+ "1 host_id uuid/uuid NOT NULL",+ "2 pid integer/int4 NOT NULL",+ "3 nonce text/text NOT NULL",+ "4 pid_ns text/text NULL",+ "5 kind text/text NOT NULL",+ "6 mode text/text NOT NULL",+ "7 started_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "8 renewed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 restart_required boolean/bool NOT NULL DEFAULT false",+ "10 root_barrier_age_ms integer/int4 NULL",+ "11 pool jsonb/jsonb NULL",+ "12 host_json_path text/text NOT NULL",+ "13 persistence_home text/text NOT NULL",+ "14 minted_under jsonb/jsonb NULL",+ "15 version text/text NOT NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_counters": {"columns": ["1 key text/text NOT NULL",diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.jsonindex 3518c74a66..71694b9936 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json@@ -207,6 +207,8 @@"persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",+ "persistence_consumers.persistence_consumers_mode_check": "c CHECK ((mode = ANY (ARRAY['probing'::text, 'full'::text, 'waiter_only'::text, 'promoted'::text])))",+ "persistence_consumers.persistence_consumers_pkey": "p PRIMARY KEY (host_id, pid, nonce)","persistence_counters.persistence_counters_intent_bytes_check": "c CHECK ((intent_bytes >= 0))","persistence_counters.persistence_counters_lifetime_ids_check": "c CHECK ((lifetime_ids >= 0))","persistence_counters.persistence_counters_outstanding_count_check": "c CHECK ((outstanding_count >= 0))",@@ -622,6 +624,9 @@"persistence_brain": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_consumers": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_counters": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -1033,6 +1038,7 @@"pages_source_path_name_idx": "CREATE INDEX pages_source_path_name_idx ON public.pages USING btree (source_id, regexp_replace(replace(btrim(source_path), chr(92), '/'::text), '^.*/'::text, ''::text)) WHERE (source_path IS NOT NULL)","pages_source_slug_key": "CREATE UNIQUE INDEX pages_source_slug_key ON public.pages USING btree (source_id, slug)","persistence_brain_pkey": "CREATE UNIQUE INDEX persistence_brain_pkey ON public.persistence_brain USING btree (singleton)",+ "persistence_consumers_pkey": "CREATE UNIQUE INDEX persistence_consumers_pkey ON public.persistence_consumers USING btree (host_id, pid, nonce)","persistence_counters_pkey": "CREATE UNIQUE INDEX persistence_counters_pkey ON public.persistence_counters USING btree (key)","persistence_effects_parked": "CREATE INDEX persistence_effects_parked ON public.persistence_effects USING btree (id) WHERE (data ? 'parked'::text)","persistence_effects_pending": "CREATE INDEX persistence_effects_pending ON public.persistence_effects USING btree (next_attempt_at, id) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text]))",@@ -1043,6 +1049,7 @@"persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",+ "persistence_requests_committed_watermark": "CREATE INDEX persistence_requests_committed_watermark ON public.persistence_requests USING btree (worktree_id, completed_at DESC) WHERE (state = 'committed'::text)","persistence_requests_database_pending": "CREATE INDEX persistence_requests_database_pending ON public.persistence_requests USING btree (source_incarnation, sequence) WHERE ((worktree_id IS NULL) AND (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text])))","persistence_requests_pending": "CREATE INDEX persistence_requests_pending ON public.persistence_requests USING btree (worktree_id, sequence) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text]))","persistence_requests_pkey": "CREATE UNIQUE INDEX persistence_requests_pkey ON public.persistence_requests USING btree (id)",@@ -2451,6 +2458,26 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_consumers": {+ "columns": [+ "1 host_id uuid/uuid NOT NULL",+ "2 pid integer/int4 NOT NULL",+ "3 nonce text/text NOT NULL",+ "4 pid_ns text/text NULL",+ "5 kind text/text NOT NULL",+ "6 mode text/text NOT NULL",+ "7 started_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "8 renewed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 restart_required boolean/bool NOT NULL DEFAULT false",+ "10 root_barrier_age_ms integer/int4 NULL",+ "11 pool jsonb/jsonb NULL",+ "12 host_json_path text/text NOT NULL",+ "13 persistence_home text/text NOT NULL",+ "14 minted_under jsonb/jsonb NULL",+ "15 version text/text NOT NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_counters": {"columns": ["1 key text/text NOT NULL",diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.jsonindex a56fe0fb3a..b278997035 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json@@ -207,6 +207,8 @@"persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",+ "persistence_consumers.persistence_consumers_mode_check": "c CHECK ((mode = ANY (ARRAY['probing'::text, 'full'::text, 'waiter_only'::text, 'promoted'::text])))",+ "persistence_consumers.persistence_consumers_pkey": "p PRIMARY KEY (host_id, pid, nonce)","persistence_counters.persistence_counters_intent_bytes_check": "c CHECK ((intent_bytes >= 0))","persistence_counters.persistence_counters_lifetime_ids_check": "c CHECK ((lifetime_ids >= 0))","persistence_counters.persistence_counters_outstanding_count_check": "c CHECK ((outstanding_count >= 0))",@@ -622,6 +624,9 @@"persistence_brain": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_consumers": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_counters": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -1029,6 +1034,7 @@"pages_source_path_name_idx": "CREATE INDEX pages_source_path_name_idx ON public.pages USING btree (source_id, regexp_replace(replace(btrim(source_path), chr(92), '/'::text), '^.*/'::text, ''::text)) WHERE (source_path IS NOT NULL)","pages_source_slug_key": "CREATE UNIQUE INDEX pages_source_slug_key ON public.pages USING btree (source_id, slug)","persistence_brain_pkey": "CREATE UNIQUE INDEX persistence_brain_pkey ON public.persistence_brain USING btree (singleton)",+ "persistence_consumers_pkey": "CREATE UNIQUE INDEX persistence_consumers_pkey ON public.persistence_consumers USING btree (host_id, pid, nonce)","persistence_counters_pkey": "CREATE UNIQUE INDEX persistence_counters_pkey ON public.persistence_counters USING btree (key)","persistence_effects_parked": "CREATE INDEX persistence_effects_parked ON public.persistence_effects USING btree (id) WHERE (data ? 'parked'::text)","persistence_effects_pending": "CREATE INDEX persistence_effects_pending ON public.persistence_effects USING btree (next_attempt_at, id) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text]))",@@ -1039,6 +1045,7 @@"persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",+ "persistence_requests_committed_watermark": "CREATE INDEX persistence_requests_committed_watermark ON public.persistence_requests USING btree (worktree_id, completed_at DESC) WHERE (state = 'committed'::text)","persistence_requests_database_pending": "CREATE INDEX persistence_requests_database_pending ON public.persistence_requests USING btree (source_incarnation, sequence) WHERE ((worktree_id IS NULL) AND (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text])))","persistence_requests_pending": "CREATE INDEX persistence_requests_pending ON public.persistence_requests USING btree (worktree_id, sequence) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text]))","persistence_requests_pkey": "CREATE UNIQUE INDEX persistence_requests_pkey ON public.persistence_requests USING btree (id)",@@ -2447,6 +2454,26 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_consumers": {+ "columns": [+ "1 host_id uuid/uuid NOT NULL",+ "2 pid integer/int4 NOT NULL",+ "3 nonce text/text NOT NULL",+ "4 pid_ns text/text NULL",+ "5 kind text/text NOT NULL",+ "6 mode text/text NOT NULL",+ "7 started_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "8 renewed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 restart_required boolean/bool NOT NULL DEFAULT false",+ "10 root_barrier_age_ms integer/int4 NULL",+ "11 pool jsonb/jsonb NULL",+ "12 host_json_path text/text NOT NULL",+ "13 persistence_home text/text NOT NULL",+ "14 minted_under jsonb/jsonb NULL",+ "15 version text/text NOT NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_counters": {"columns": ["1 key text/text NOT NULL",diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json b/test/fixtures/goldens/catalog/pglite-schema-blob-default.jsonindex fa606b9089..9ba04040fc 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-default.json@@ -148,6 +148,8 @@"persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",+ "persistence_consumers.persistence_consumers_mode_check": "c CHECK ((mode = ANY (ARRAY['probing'::text, 'full'::text, 'waiter_only'::text, 'promoted'::text])))",+ "persistence_consumers.persistence_consumers_pkey": "p PRIMARY KEY (host_id, pid, nonce)","persistence_counters.persistence_counters_intent_bytes_check": "c CHECK ((intent_bytes >= 0))","persistence_counters.persistence_counters_lifetime_ids_check": "c CHECK ((lifetime_ids >= 0))","persistence_counters.persistence_counters_outstanding_count_check": "c CHECK ((outstanding_count >= 0))",@@ -467,6 +469,9 @@"persistence_brain": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_consumers": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_counters": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -754,12 +759,14 @@"pages_pkey": "CREATE UNIQUE INDEX pages_pkey ON public.pages USING btree (id)","pages_source_slug_key": "CREATE UNIQUE INDEX pages_source_slug_key ON public.pages USING btree (source_id, slug)","persistence_brain_pkey": "CREATE UNIQUE INDEX persistence_brain_pkey ON public.persistence_brain USING btree (singleton)",+ "persistence_consumers_pkey": "CREATE UNIQUE INDEX persistence_consumers_pkey ON public.persistence_consumers USING btree (host_id, pid, nonce)","persistence_counters_pkey": "CREATE UNIQUE INDEX persistence_counters_pkey ON public.persistence_counters USING btree (key)","persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",+ "persistence_requests_committed_watermark": "CREATE INDEX persistence_requests_committed_watermark ON public.persistence_requests USING btree (worktree_id, completed_at DESC) WHERE (state = 'committed'::text)","persistence_requests_database_pending": "CREATE INDEX persistence_requests_database_pending ON public.persistence_requests USING btree (source_incarnation, sequence) WHERE ((worktree_id IS NULL) AND (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text])))","persistence_requests_pending": "CREATE INDEX persistence_requests_pending ON public.persistence_requests USING btree (worktree_id, sequence) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text]))","persistence_requests_pkey": "CREATE UNIQUE INDEX persistence_requests_pkey ON public.persistence_requests USING btree (id)",@@ -1797,6 +1804,26 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_consumers": {+ "columns": [+ "1 host_id uuid/uuid NOT NULL",+ "2 pid integer/int4 NOT NULL",+ "3 nonce text/text NOT NULL",+ "4 pid_ns text/text NULL",+ "5 kind text/text NOT NULL",+ "6 mode text/text NOT NULL",+ "7 started_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "8 renewed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 restart_required boolean/bool NOT NULL DEFAULT false",+ "10 root_barrier_age_ms integer/int4 NULL",+ "11 pool jsonb/jsonb NULL",+ "12 host_json_path text/text NOT NULL",+ "13 persistence_home text/text NOT NULL",+ "14 minted_under jsonb/jsonb NULL",+ "15 version text/text NOT NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_counters": {"columns": ["1 key text/text NOT NULL",diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.jsonindex 6704135f17..47a621af8f 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json@@ -148,6 +148,8 @@"persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",+ "persistence_consumers.persistence_consumers_mode_check": "c CHECK ((mode = ANY (ARRAY['probing'::text, 'full'::text, 'waiter_only'::text, 'promoted'::text])))",+ "persistence_consumers.persistence_consumers_pkey": "p PRIMARY KEY (host_id, pid, nonce)","persistence_counters.persistence_counters_intent_bytes_check": "c CHECK ((intent_bytes >= 0))","persistence_counters.persistence_counters_lifetime_ids_check": "c CHECK ((lifetime_ids >= 0))","persistence_counters.persistence_counters_outstanding_count_check": "c CHECK ((outstanding_count >= 0))",@@ -467,6 +469,9 @@"persistence_brain": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_consumers": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_counters": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -754,12 +759,14 @@"pages_pkey": "CREATE UNIQUE INDEX pages_pkey ON public.pages USING btree (id)","pages_source_slug_key": "CREATE UNIQUE INDEX pages_source_slug_key ON public.pages USING btree (source_id, slug)","persistence_brain_pkey": "CREATE UNIQUE INDEX persistence_brain_pkey ON public.persistence_brain USING btree (singleton)",+ "persistence_consumers_pkey": "CREATE UNIQUE INDEX persistence_consumers_pkey ON public.persistence_consumers USING btree (host_id, pid, nonce)","persistence_counters_pkey": "CREATE UNIQUE INDEX persistence_counters_pkey ON public.persistence_counters USING btree (key)","persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",+ "persistence_requests_committed_watermark": "CREATE INDEX persistence_requests_committed_watermark ON public.persistence_requests USING btree (worktree_id, completed_at DESC) WHERE (state = 'committed'::text)","persistence_requests_database_pending": "CREATE INDEX persistence_requests_database_pending ON public.persistence_requests USING btree (source_incarnation, sequence) WHERE ((worktree_id IS NULL) AND (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text])))","persistence_requests_pending": "CREATE INDEX persistence_requests_pending ON public.persistence_requests USING btree (worktree_id, sequence) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text]))","persistence_requests_pkey": "CREATE UNIQUE INDEX persistence_requests_pkey ON public.persistence_requests USING btree (id)",@@ -1797,6 +1804,26 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_consumers": {+ "columns": [+ "1 host_id uuid/uuid NOT NULL",+ "2 pid integer/int4 NOT NULL",+ "3 nonce text/text NOT NULL",+ "4 pid_ns text/text NULL",+ "5 kind text/text NOT NULL",+ "6 mode text/text NOT NULL",+ "7 started_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "8 renewed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 restart_required boolean/bool NOT NULL DEFAULT false",+ "10 root_barrier_age_ms integer/int4 NULL",+ "11 pool jsonb/jsonb NULL",+ "12 host_json_path text/text NOT NULL",+ "13 persistence_home text/text NOT NULL",+ "14 minted_under jsonb/jsonb NULL",+ "15 version text/text NOT NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_counters": {"columns": ["1 key text/text NOT NULL",diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.jsonindex c0c3934a06..5f79617bdd 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json@@ -148,6 +148,8 @@"persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",+ "persistence_consumers.persistence_consumers_mode_check": "c CHECK ((mode = ANY (ARRAY['probing'::text, 'full'::text, 'waiter_only'::text, 'promoted'::text])))",+ "persistence_consumers.persistence_consumers_pkey": "p PRIMARY KEY (host_id, pid, nonce)","persistence_counters.persistence_counters_intent_bytes_check": "c CHECK ((intent_bytes >= 0))","persistence_counters.persistence_counters_lifetime_ids_check": "c CHECK ((lifetime_ids >= 0))","persistence_counters.persistence_counters_outstanding_count_check": "c CHECK ((outstanding_count >= 0))",@@ -467,6 +469,9 @@"persistence_brain": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "persistence_consumers": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"persistence_counters": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],@@ -753,12 +758,14 @@"pages_pkey": "CREATE UNIQUE INDEX pages_pkey ON public.pages USING btree (id)","pages_source_slug_key": "CREATE UNIQUE INDEX pages_source_slug_key ON public.pages USING btree (source_id, slug)","persistence_brain_pkey": "CREATE UNIQUE INDEX persistence_brain_pkey ON public.persistence_brain USING btree (singleton)",+ "persistence_consumers_pkey": "CREATE UNIQUE INDEX persistence_consumers_pkey ON public.persistence_consumers USING btree (host_id, pid, nonce)","persistence_counters_pkey": "CREATE UNIQUE INDEX persistence_counters_pkey ON public.persistence_counters USING btree (key)","persistence_effects_pkey": "CREATE UNIQUE INDEX persistence_effects_pkey ON public.persistence_effects USING btree (id)","persistence_effects_request_id_kind_key": "CREATE UNIQUE INDEX persistence_effects_request_id_kind_key ON public.persistence_effects USING btree (request_id, kind)","persistence_host_bindings_pkey": "CREATE UNIQUE INDEX persistence_host_bindings_pkey ON public.persistence_host_bindings USING btree (worktree_id, host_id)","persistence_local_writers_credential_hash_key": "CREATE UNIQUE INDEX persistence_local_writers_credential_hash_key ON public.persistence_local_writers USING btree (credential_hash)","persistence_local_writers_pkey": "CREATE UNIQUE INDEX persistence_local_writers_pkey ON public.persistence_local_writers USING btree (id)",+ "persistence_requests_committed_watermark": "CREATE INDEX persistence_requests_committed_watermark ON public.persistence_requests USING btree (worktree_id, completed_at DESC) WHERE (state = 'committed'::text)","persistence_requests_database_pending": "CREATE INDEX persistence_requests_database_pending ON public.persistence_requests USING btree (source_incarnation, sequence) WHERE ((worktree_id IS NULL) AND (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text])))","persistence_requests_pending": "CREATE INDEX persistence_requests_pending ON public.persistence_requests USING btree (worktree_id, sequence) WHERE (state = ANY (ARRAY['queued'::text, 'running'::text, 'recovering'::text]))","persistence_requests_pkey": "CREATE UNIQUE INDEX persistence_requests_pkey ON public.persistence_requests USING btree (id)",@@ -1796,6 +1803,26 @@],"flags": "relkind=r rls=false force_rls=false"},+ "persistence_consumers": {+ "columns": [+ "1 host_id uuid/uuid NOT NULL",+ "2 pid integer/int4 NOT NULL",+ "3 nonce text/text NOT NULL",+ "4 pid_ns text/text NULL",+ "5 kind text/text NOT NULL",+ "6 mode text/text NOT NULL",+ "7 started_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "8 renewed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "9 restart_required boolean/bool NOT NULL DEFAULT false",+ "10 root_barrier_age_ms integer/int4 NULL",+ "11 pool jsonb/jsonb NULL",+ "12 host_json_path text/text NOT NULL",+ "13 persistence_home text/text NOT NULL",+ "14 minted_under jsonb/jsonb NULL",+ "15 version text/text NOT NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },"persistence_counters": {"columns": ["1 key text/text NOT NULL",diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.jsonindex affc654c04..f34660c6c7 100644--- a/test/fixtures/goldens/migrations/records.json+++ b/test/fixtures/goldens/migrations/records.json@@ -1,6 +1,6 @@{"golden": {- "count": 215,+ "count": 216,"gaps": [17,18,@@ -13,6 +13,7 @@"FACT_UNLINKED_INDEX_SQL": "87dcf23c3fa570d93bfb214b6bbb024faa9ff9bff227aa78869a29580be03298","ISSUANCE_CLOCK_SLACK_SECONDS": "8f36c80392df6f9b9c754826289b63969d9d41ca8955213291e4413d614dce35","PAGES_RECONCILE_NAME_INDEXES": "8805e35341b22324b932b1cc05030cc8f2bfc95532bf810ec35330783f29c59a",+ "PERSISTENCE_COMMITTED_WATERMARK_INDEX": "f472fa0acb542c1caebaaa3bc69fb2da1647e5e201239429fc02ccef0d669533","PERSISTENCE_DATABASE_PENDING_INDEX_SQL": "6e0f618be33d037454933ea4dea11438413d45aef35d3bd4f33e89624d6e199e","PERSISTENCE_EFFECT_PARKED_INDEX_SQL": "0107863883415378d7c0dce7a0cbd5311c2c5a59fc0f81917cc8b767fd235cf2","PERSISTENCE_SYNC_RUN_INDEXES": "e1b12613c5fd2facb850e6857b0bddcf49b2478ec258fa226fe15e71e55df9c1",@@ -36,7 +37,7 @@"sqlQueryForEngine": "71fb1ccec1b22cdc1662876dbd8c17ed81e9ab83485c6965cdf5caa4fc4a4ab5","verifyProjectionStatistics": "59d9ccfea1c53384d8607874a51209a9c2dfd51b2b85a2cb6269fa4120faf1f3"},- "latest": 220,+ "latest": 221,"records": [{"handler": {@@ -2230,8 +2231,8 @@"idempotent": true,"name": "durable_concurrent_persistence","sql": {- "length": 10185,- "sha256": "5c29e2ba0eed52dbab814e8bb2e99eda48c9ccd26f4d97f2274adc5c1712a8b7"+ "length": 10954,+ "sha256": "5ba8c5f4f897b93b1c177eaeef5dfb1ce59a124e9e14485ce5795d306c8d514f"},"sqlFor": "absent","transaction": "absent",@@ -3267,6 +3268,29 @@"transaction": "absent","verify": "absent","version": 220+ },+ {+ "handler": {+ "form": "arrow",+ "helpers": [+ "PERSISTENCE_COMMITTED_WATERMARK_INDEX",+ "buildIndexOnline",+ "dropInvalidConcurrentIndex",+ "migrationNotice",+ "quietMigrationNotices"+ ],+ "sha256": "2c85f48116c5262f6ddff8e57665135247fc5867480c069d70c835e3c27e837d"+ },+ "idempotent": true,+ "name": "persistence_consumers",+ "sql": {+ "length": 617,+ "sha256": "cd4f82da89b693d122d4591ebbbb692178f1d7b497349c2faa44fc165c1114d4"+ },+ "sqlFor": "absent",+ "transaction": "absent",+ "verify": "absent",+ "version": 221}],"versions": [@@ -3484,7 +3508,8 @@217,218,219,- 220+ 220,+ 221]},"normalizer": "migrations-record-v1"