Fix cellular birth publication function
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (postgres) (push) Failing after 32m39s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (checks) (push) Successful in 5s
Foundation / checks (client) (push) Successful in 4s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 5s
Foundation / checks (network) (push) Successful in 4s
Foundation / checks (tsan) (push) Successful in 5s
Foundation / checks (postgres) (push) Failing after 32m39s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
-- PL/pgSQL's local record named `b` shadowed the birth-query aliases below.
|
||||
-- Renaming the loop record lets the duplicate checks resolve their query alias.
|
||||
CREATE OR REPLACE FUNCTION evolution.publish_cellular_checkpoint(p_manifest bytea,
|
||||
p_decisions bytea, p_actions bytea, p_trace bytea)
|
||||
RETURNS TABLE(region_frame evolution.u64, head_sequence evolution.u64, head_commit uuid,
|
||||
head_digest text, head_tick evolution.u64)
|
||||
LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
|
||||
DECLARE
|
||||
c evolution.checkpoint_manifest := evolution.parse_checkpoint_manifest(p_manifest);
|
||||
birth_row record;
|
||||
r evolution.life_reservations%ROWTYPE;
|
||||
BEGIN
|
||||
IF c.profile <> 4 OR c.commit_sequence = 0 OR p_actions IS NULL THEN
|
||||
RAISE EXCEPTION 'invalid cellular publication' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
PERFORM evolution.check_cellular_action_block(p_actions, c.begin_tick, c.end_tick);
|
||||
PERFORM * FROM evolution.cellular_births(p_trace, p_manifest);
|
||||
IF EXISTS (SELECT b.account_id FROM evolution.cellular_births(p_trace, p_manifest) b
|
||||
GROUP BY b.account_id HAVING count(*) > 1)
|
||||
OR EXISTS (SELECT b.identity FROM evolution.cellular_births(p_trace, p_manifest) b
|
||||
GROUP BY b.identity HAVING count(*) > 1) THEN
|
||||
RAISE EXCEPTION 'duplicate cellular birth identity' USING ERRCODE = '22023';
|
||||
END IF;
|
||||
PERFORM evolution.check_region_lease(c.world_id, c.region_id, c.holder, c.epoch);
|
||||
-- The lease lock fences competing commits. Exact retries are accepted only
|
||||
-- when the immutable binding rows agree with every birth in the trace.
|
||||
IF EXISTS (SELECT 1 FROM evolution.region_commits x WHERE x.commit_id = c.commit_id) THEN
|
||||
IF NOT evolution.cellular_birth_bindings_match(c.world_id, c.commit_id, p_trace, p_manifest) THEN
|
||||
RAISE EXCEPTION 'cellular birth evidence differs on retry' USING ERRCODE = 'EVL07';
|
||||
END IF;
|
||||
RETURN QUERY SELECT * FROM evolution.publish_cellular_checkpoint(
|
||||
p_manifest, p_decisions, p_actions);
|
||||
RETURN;
|
||||
END IF;
|
||||
-- Lock accounts in stable order and require the exact current control generation
|
||||
-- and previously allocated request identity before inserting any binding.
|
||||
FOR birth_row IN SELECT * FROM evolution.cellular_births(p_trace, p_manifest) ORDER BY account_id LOOP
|
||||
PERFORM evolution.check_life_control(c.world_id, c.region_id, c.holder, c.epoch,
|
||||
birth_row.account_id, birth_row.generation);
|
||||
SELECT * INTO r FROM evolution.life_reservations x WHERE x.world_id = c.world_id
|
||||
AND x.account_id = birth_row.account_id AND x.request_id = birth_row.request_id FOR UPDATE;
|
||||
IF NOT FOUND OR r.region_id <> c.region_id OR r.identity <> birth_row.identity
|
||||
OR r.rejection <> 0 OR r.rules <> 1
|
||||
OR EXISTS (SELECT 1 FROM evolution.primitive_life_bindings x
|
||||
WHERE x.world_id = c.world_id AND x.account_id = birth_row.account_id) THEN
|
||||
RAISE EXCEPTION 'cellular birth reservation conflicts' USING ERRCODE = 'EVL16';
|
||||
END IF;
|
||||
END LOOP;
|
||||
FOR birth_row IN SELECT * FROM evolution.cellular_births(p_trace, p_manifest) ORDER BY account_id LOOP
|
||||
PERFORM evolution.check_life_control(c.world_id, c.region_id, c.holder, c.epoch,
|
||||
birth_row.account_id, birth_row.generation);
|
||||
END LOOP;
|
||||
INSERT INTO evolution.primitive_life_bindings(world_id, account_id, request_id, born, commit_id)
|
||||
SELECT c.world_id, b.account_id, b.request_id, b.born, c.commit_id
|
||||
FROM evolution.cellular_births(p_trace, p_manifest) b;
|
||||
RETURN QUERY SELECT * FROM evolution.publish_cellular_checkpoint(
|
||||
p_manifest, p_decisions, p_actions);
|
||||
END $$;
|
||||
|
||||
INSERT INTO evolution.schema_migrations(version, sha256) VALUES (31, :'migration_sha_31');
|
||||
+15
-3
@@ -104,7 +104,10 @@ SELECT EXISTS (SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname='evolution')
|
||||
SELECT right(:'history', length(',28:' || :'migration_sha_28')) = ',28:' || :'migration_sha_28' AS at_v28 \gset
|
||||
SELECT right(:'history', length(',29:' || :'migration_sha_29')) = ',29:' || :'migration_sha_29' AS at_v29 \gset
|
||||
SELECT right(:'history', length(',30:' || :'migration_sha_30')) = ',30:' || :'migration_sha_30' AS at_v30 \gset
|
||||
\if :at_v30
|
||||
SELECT right(:'history', length(',31:' || :'migration_sha_31')) = ',31:' || :'migration_sha_31' AS at_v31 \gset
|
||||
\if :at_v31
|
||||
\elif :at_v30
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\elif :at_v29
|
||||
\elif :at_v28
|
||||
\ir 0029_cellular_mutation_reservations.sql
|
||||
@@ -456,7 +459,8 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
coalesce(max(version), 0) = 27 AS at_v27,
|
||||
coalesce(max(version), 0) = 28 AS at_v28,
|
||||
coalesce(max(version), 0) = 29 AS at_v29,
|
||||
coalesce(max(version), 0) = 30 AS at_v30
|
||||
coalesce(max(version), 0) = 30 AS at_v30,
|
||||
coalesce(max(version), 0) = 31 AS at_v31
|
||||
FROM evolution.schema_migrations \gset
|
||||
\if :at_v24
|
||||
\ir 0025_cellular_v2_bundle.sql
|
||||
@@ -465,29 +469,37 @@ SELECT coalesce(max(version), 0) = 24 AS at_v24,
|
||||
\ir 0028_cellular_v3_trace_bounds.sql
|
||||
\ir 0029_cellular_mutation_reservations.sql
|
||||
\ir 0030_cellular_birth_publication_binding.sql
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\elif :at_v25
|
||||
\ir 0026_cellular_profile_migration.sql
|
||||
\ir 0027_cellular_v3_migration.sql
|
||||
\ir 0028_cellular_v3_trace_bounds.sql
|
||||
\ir 0029_cellular_mutation_reservations.sql
|
||||
\ir 0030_cellular_birth_publication_binding.sql
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\elif :at_v26
|
||||
\ir 0027_cellular_v3_migration.sql
|
||||
\ir 0028_cellular_v3_trace_bounds.sql
|
||||
\ir 0029_cellular_mutation_reservations.sql
|
||||
\ir 0030_cellular_birth_publication_binding.sql
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\elif :at_v27
|
||||
\ir 0028_cellular_v3_trace_bounds.sql
|
||||
\ir 0029_cellular_mutation_reservations.sql
|
||||
\ir 0030_cellular_birth_publication_binding.sql
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\elif :at_v28
|
||||
\ir 0029_cellular_mutation_reservations.sql
|
||||
\ir 0030_cellular_birth_publication_binding.sql
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\elif :at_v29
|
||||
\ir 0030_cellular_birth_publication_binding.sql
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\elif :at_v30
|
||||
\ir 0031_fix_cellular_birth_publication_record.sql
|
||||
\elif :at_v31
|
||||
\else
|
||||
\echo 'Unknown or changed migration history after v30'
|
||||
\echo 'Unknown or changed migration history after v31'
|
||||
DO $$ BEGIN RAISE EXCEPTION 'unknown or changed migration history'; END $$;
|
||||
\endif
|
||||
-- Effective-privilege audit on every run, including no-ops (ADR-0060). Attributes
|
||||
|
||||
Reference in New Issue
Block a user