mirror of
https://github.com/block/buzz.git
synced 2026-11-17 06:41:58 +00:00
fix(db): fail invite repair when validation remains nonzero
Co-authored-by: Honor <e0bf479eeebe47dde1e35705212a4df70616a7bc834d907ddfb18cf0405f8b1b@seiler-test.communities.public.builderlabstaging.xyz> Signed-off-by: Brad Seiler <seiler@squareup.com>
This commit is contained in:
@@ -446,12 +446,7 @@ pub(super) async fn run_invite_repair_script(pool: &PgPool) -> String {
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr),
|
||||
);
|
||||
let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
|
||||
assert!(
|
||||
stdout.lines().any(|line| line.trim() == "0"),
|
||||
"repair validation did not return zero unrepaired invites:\n{stdout}"
|
||||
);
|
||||
stdout
|
||||
String::from_utf8_lossy(&output.stdout).into_owned()
|
||||
}
|
||||
|
||||
async fn invite_revocation_state(pool: &PgPool) -> Vec<(Uuid, Option<DateTime<Utc>>, bool)> {
|
||||
|
||||
@@ -148,7 +148,7 @@ $$;
|
||||
-- Expected result: 0. Every legacy marker in an active community has been
|
||||
-- examined and cleared; every currently active ban has durably revoked its
|
||||
-- invite. Markers in fenced communities remain for a later repair run.
|
||||
SELECT count(*) AS unrepaired_invites
|
||||
SELECT count(*) AS unrepaired_invites, count(*) = 0 AS repair_complete
|
||||
FROM relay_invites AS invite
|
||||
JOIN communities AS community ON community.id = invite.community_id
|
||||
CROSS JOIN LATERAL (
|
||||
@@ -182,4 +182,12 @@ WHERE community.deletion_state = 'active'
|
||||
OR restriction.ban_expires_at > clock_timestamp())
|
||||
)
|
||||
)
|
||||
);
|
||||
)\gset
|
||||
\echo unrepaired_invites
|
||||
\echo :unrepaired_invites
|
||||
\if :repair_complete
|
||||
\else
|
||||
DO $$ BEGIN
|
||||
RAISE EXCEPTION 'invite repair incomplete; keep admission closed and rerun';
|
||||
END $$;
|
||||
\endif
|
||||
|
||||
Reference in New Issue
Block a user