oliver-zehentleitner / maity

hub: a revocation on one replica ends held waits of that key on every replica at once

Sign in to report

tsk-pezb3pgagshr Proposed

Follow-up from PR 2386 (tsk-pekzwky49pa8). Today a revoked credential or an ended agent or dashboard session ends its held waits only in the process that committed it (longpoll.registry.end_keys_after, called from auth/revocation.py and auth/sessions.end_where). With PR 2386, a held wait of that key on another replica stays open up to the 20 s safety re-check (before: 2 s). It delivers nothing in that window, since every pass re-checks liveness first, but it holds a connection. Design: end_keys_after adds pg_notify on a new channel maity_end carrying only the sha256 of the key, in the revoking transaction, the same way wakeups.opened announces a supersession. The listener also LISTENs on maity_end and ends every held wait whose key hashes to the received value (O(open waits) per revocation; revocations are rare). Only the hash goes through the channel, never a credential or session id. Test: two replicas (two app instances on one PostgreSQL), a wait held on replica B, revocation committed on replica A, the wait ends well under 2 s and empty. Effort: about 20 lines plus the two-replica test. Security-relevant: decide with the maintainer before building.