fix(db): make invite repair run budget configurable

Retain the finite default and explain timeout recovery across committed batches so large repairs can finish with a reviewed invocation budget.

Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz>
Signed-off-by: Brad Seiler <seiler@squareup.com>
This commit is contained in:
Brad Seiler
2026-11-06 18:19:06 -05:00
committed by GitHub
parent be76ecec39
commit b068d59e5f
2 changed files with 17 additions and 1 deletions

View File

@@ -231,6 +231,12 @@ psql -X -v ON_ERROR_STOP=1 -f scripts/maintenance/backfill_invite_revocations.sq
Run it as a top-level script, outside any caller transaction. The final query
must report `0` unrepaired invites in active communities. Run it twice; the
second run must keep zero and leave revocation timestamps and markers unchanged.
The default two-minute statement timeout covers the entire repair invocation,
not each batch. A timeout preserves committed batches, rolls back the current
batch and skips the final query; it is not a successful zero check. Keep the
same writer controls in place and rerun. If scanning already repaired rows
exhausts that budget, pass a larger finite budget, for example
`psql -X -v ON_ERROR_STOP=1 -v invite_repair_timeout=10min -f scripts/maintenance/backfill_invite_revocations.sql`.
Review fenced communities separately and keep their admission closed until they
can be repaired under the same controls.

View File

@@ -12,9 +12,19 @@
-- before clearing legacy_admission on every invite row. Skipped communities
-- retain the marker and remain fail-closed until a later run. The script is
-- idempotent; rerun it after a failure.
-- statement_timeout bounds the entire DO invocation, including all batches;
-- COMMIT does not restart it. On timeout, committed batches remain repaired,
-- the current batch rolls back, and ON_ERROR_STOP skips the final zero check.
-- Keep admission closed and rerun. If scanning the repaired prefix consumes
-- the budget, choose a larger finite invocation budget with psql's
-- -v invite_repair_timeout=10min (the default is 2min).
\set ON_ERROR_STOP on
\if :{?invite_repair_timeout}
\else
\set invite_repair_timeout 2min
\endif
SET lock_timeout = '5s';
SET statement_timeout = '2min';
SET statement_timeout = :'invite_repair_timeout';
DO $$
DECLARE