mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
wip: checkpoint deletion remediation lanes
Co-authored-by: npub122y0pqkertljmedu303rl0aqrj3w8pvu43t6jxm6875lzg6f2pwqegc3xc <5288f082d91aff2de5bc8be23fbfa01ca2e3859cac57a91b7a3fa9f12349505c@buzz.block.builderlab.xyz> Signed-off-by: npub122y0pqkertljmedu303rl0aqrj3w8pvu43t6jxm6875lzg6f2pwqegc3xc <5288f082d91aff2de5bc8be23fbfa01ca2e3859cac57a91b7a3fa9f12349505c@buzz.block.builderlab.xyz>
This commit is contained in:
parent
4ac9ca009d
commit
4db5395dbe
+25
-3
@@ -1092,6 +1092,8 @@ CREATE TABLE community_deletion_requests (
|
||||
reason TEXT,
|
||||
schema_manifest JSONB,
|
||||
storage_manifest JSONB,
|
||||
destructive_storage_manifest JSONB,
|
||||
destructive_storage_frozen_at TIMESTAMPTZ,
|
||||
inventory_manifest JSONB,
|
||||
inventory_digest BYTEA CHECK (inventory_digest IS NULL OR length(inventory_digest) = 32),
|
||||
inventory_frozen_at TIMESTAMPTZ,
|
||||
@@ -1153,6 +1155,22 @@ CREATE TABLE community_deletion_retention_exceptions (
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (request_id, exception_key)
|
||||
);
|
||||
CREATE TABLE community_serving_write_leases (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
community_id UUID NOT NULL REFERENCES communities(id),
|
||||
operation TEXT NOT NULL,
|
||||
owner TEXT NOT NULL,
|
||||
generation BIGINT NOT NULL DEFAULT 1 CHECK (generation > 0),
|
||||
-- Community fence generation observed when this lease was acquired.
|
||||
fence_generation BIGINT NOT NULL CHECK (fence_generation >= 0),
|
||||
lease_until TIMESTAMPTZ NOT NULL,
|
||||
heartbeat_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
UNIQUE (community_id, id)
|
||||
);
|
||||
CREATE INDEX community_serving_write_leases_active
|
||||
ON community_serving_write_leases (community_id, lease_until);
|
||||
|
||||
CREATE TABLE community_deletion_executor_heartbeats (
|
||||
executor_id TEXT PRIMARY KEY,
|
||||
mode TEXT NOT NULL CHECK (mode IN ('run', 'drain', 'worker')),
|
||||
@@ -1167,6 +1185,7 @@ INSERT INTO _operator_global_tables (table_name, reason) VALUES
|
||||
('community_deletion_approvals', 'deployment operator destructive approvals'),
|
||||
('community_deletion_checkpoints', 'deployment deletion executor checkpoints and failures'),
|
||||
('community_deletion_retention_exceptions', 'deployment retention holds and expiry exceptions'),
|
||||
('community_serving_write_leases', 'deployment serving side-effect leases drained by deletion'),
|
||||
('community_deletion_executor_heartbeats', 'deployment deletion worker liveness');
|
||||
|
||||
CREATE FUNCTION community_deletion_lock_key(target UUID) RETURNS BIGINT
|
||||
@@ -1212,8 +1231,11 @@ DECLARE
|
||||
expected_generation BIGINT;
|
||||
BEGIN
|
||||
IF TG_OP = 'DELETE' THEN
|
||||
RAISE EXCEPTION 'community tombstones are permanent'
|
||||
USING ERRCODE = 'object_not_in_prerequisite_state';
|
||||
IF OLD.deletion_state <> 'active' OR OLD.deleted_at IS NOT NULL THEN
|
||||
RAISE EXCEPTION 'community tombstones are permanent'
|
||||
USING ERRCODE = 'object_not_in_prerequisite_state';
|
||||
END IF;
|
||||
RETURN OLD;
|
||||
END IF;
|
||||
expected_generation := CASE WHEN NEW.deletion_fence_generation > OLD.deletion_fence_generation
|
||||
THEN NEW.deletion_fence_generation ELSE OLD.deletion_fence_generation END;
|
||||
@@ -1242,7 +1264,7 @@ BEGIN
|
||||
AND a.attname = 'community_id' AND NOT a.attisdropped
|
||||
AND c.relname NOT IN ('community_deletion_requests', 'community_deletion_approvals',
|
||||
'community_deletion_checkpoints', 'community_deletion_retention_exceptions',
|
||||
'community_deletion_executor_heartbeats')
|
||||
'community_serving_write_leases', 'community_deletion_executor_heartbeats')
|
||||
LOOP
|
||||
EXECUTE format('CREATE TRIGGER %I BEFORE INSERT OR UPDATE OR DELETE ON %I '
|
||||
'FOR EACH ROW EXECUTE FUNCTION enforce_community_write_fence()',
|
||||
|
||||
Reference in New Issue
Block a user