Repository navigation
fix(group): release members-only spots when a membership ends - #727
Merged
Merged
Conversation
Who's going was shown to anyone holding an RSVP or a waitlist spot on the huddl. A spot can outlive what made it possible: the huddl becomes members-only, or the person leaves the group or is removed from it. They could no longer open the huddl, yet the JSON:API and GraphQL lists still named the people going. The list now also needs what an RSVP needs: the huddl is open to everyone, or the reader is a member of its group. Lifecycle plays no part, so the list of an ended huddl, or of one whose group was archived, stays with the people who had it before. Group roles and administration still grant no exception.
Leaving a group, or being removed from it, left the person's RSVPs and waitlist spots in place. On the group's members-only huddlz they kept a seat they could not give up, on a huddl they could no longer open, and were still sent its updates, reminders and cancellation. Both actions now release the person's spots on the group's huddlz that are still open to attendance and that only members can go to, under the same huddl lock RSVPs take, and the next person waiting gets the seat and the usual notice. Spots on huddlz open to everyone stay, since an RSVP there never needed the membership, and so do spots on huddlz already cancelled or ended, which are history. The person is not told separately: a removal already has its own notice.
Releasing a suspended or deleted account's spots found them through the attendee rows, which reaches only publicly visible huddlz, so spots on members-only huddlz stayed. The huddlz are now read directly. A cancelled huddl has no seat to hand on: its spots stay as history, and nobody is promoted into it.
The huddlz whose spots are released were chosen before their rows were locked, so a cancellation or an edit committing in between was missed: a suspension could promote someone into a huddl just cancelled, and leaving a group could drop an RSVP on a huddl just opened to everyone. The locked row is now checked for both. - a departing organizer's spot on a members-only draft is released too - deleting an account closes the groups it owns before releasing its spots, so nobody is given a seat at a huddl cancelled in the same breath
Each spot's group was read separately while the spots were released, so a group opened or closed at the same moment as someone leaving could have one of their RSVPs released and another kept. The group's row is locked and its visibility read once for the whole release.
Locking the group's row while releasing a leaving member's spots set a leave against other work that reaches the group and its huddlz in a different order: two members leaving together, a role change, an RSVP during an account deletion. The visibility is still read once for the whole release, so every spot is judged by the same answer.
…r-leave * origin/main: fix(api): accept only sign-in tokens on the GraphQL socket (#730) fix(huddl): tie organizer-only huddl details to the current role (#726) fix(groups): keep a group's address book with its organizers (#725) fix(discover): noindex empty filtered public discovery responses (#734)
An RSVP or waitlist place sent at the same moment as the person's own leave or removal could commit after their spots had been released, and stay on a members-only huddl with no membership behind it. Both sides are now decided under the group's row lock, the lock RSVPs, removal, role changes and huddl edits already take first: - leaving takes it before the membership row, as removal does - taking a spot checks again, once it holds the lock, that the huddl is still open to the person - account deletion locks a group it owns before its drafts, and leaves its other groups before releasing the remaining spots Every change inside a group now reaches the group, then the membership, then the huddlz, so two of them cannot wait on each other. That also ends the deadlock between a leave and a role change for the same member.
A spot released because a membership ended, or an account was suspended or deleted, changed who's going without telling anyone looking at the huddl. Only the huddl's own `:cancel_rsvp` published the change. The spot now publishes its own release on the huddl's topic, with the message open pages already reload on, so one publisher covers a spot given up and a spot released. The huddl stops publishing `:cancel_rsvp` itself, which would have announced the same change twice. - people looking at the huddl see the seat pass to the next person waiting - the person who lost access is taken off the page
Leaving while an organizer cancels the huddl can finish in either order. When the cancellation commits first the spot stays as history, as it does for any cancelled huddl, so that case now checks the membership alone. Also state that an account's own group is there to be locked before it is closed.
The page reloads when the release is announced, in its own process, and under a loaded suite that took longer than the default 100 ms the redirect assertion allows. The wait is bounded and ends as soon as the page moves.
The lock a leave takes was a function added to `RequireActiveGroup`, with `LockLifecycle` rewritten to call it. Those two files go back to what main has, and the lock lives in `GroupLock`, used by leaving and by account deletion. It locks the same row, so it still takes turns with every change that asks whether the group is active, and it asks for no more than that: a row that only points at the group is not held up behind a leave.
A weaker lock here let the same transaction ask for a stronger one later: closing a deleted account's group cancels its huddlz, then archives the group. That second request waits for rows that point at the group, and a writer of such a row can be waiting on a huddl the transaction already holds. The database counted those as deadlocks even though every test passed, because the loser was an activity entry written after commit.
…r-leave * origin/main: fix(groups): authorize membership changes against their roster (#739)
A leave now takes the group's row lock before its membership, so it waits for a removal elsewhere in the roster to commit and then goes through. That ordering is what settles a leave against the person's own RSVP.
Releasing a person's spots already took huddlz in id order. An "edit all" on a series, closing the groups of a deleted account and deleting a group for good took theirs in other orders, so each could hold a huddl the other was waiting for. All of them now lock what they will touch up front through `LockedHuddl.hold_in_order/1`: groups, then memberships, then huddlz by id. Account deletion also stops holding off rows that merely point at the account. It keeps its lock on the account at the strength that orders it against the person's other changes, and writes the account's own row last: that write changes the email, which makes every such row wait.
Adds the two interleavings that deadlocked when a leave waited for its group (archiving against a returning member's account deletion; an organizer adding a member while deleting their own account), suspension and account deletion against the person's own RSVP, every multi-huddl release against an "edit all", and deleting a group against a leave. Each test now fails if PostgreSQL reports a deadlock on any connection, including a write made after the action committed.
…account Leaving for the first time writes the person's reminder for the group, which points at the group's row. That no longer sets the two against each other, so both kinds of member are covered.
…eletion Both sides hold the group's memberships and several of its huddlz, and now take them in the same order.
This was referenced Dec 1, 2026
After merging the transient-refresh change, a huddl page whose viewer lost access visits itself again rather than redirecting directly, so the visitor sees what a fresh visit shows; transient errors still keep the page open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Leaving or being removed from a group releases upcoming RSVP and waitlist spots on its members-only huddlz. The next person waiting gets the freed seat and one promotion notice. Public drop-in spots and attendance history stay in place. Current membership is required to read archived attendance.
When departure makes an open members-only huddl unreadable, the page revisits its address and shows the same recovery page as a fresh visit. If a signed-in viewer can still read a cancelled huddl from their attendance history but its host group is hidden, a refresh takes them to their agenda.
Account deletion waits for in-flight picture uploads, key creation, memberships and invitations before cleanup. An email invitation queued behind its recipient’s deletion is refused. If the recipient changes their address instead, the invitation stays with the originally invited address. An invitation that is still pending can reach its recipient after the organizer who sent it closes their account. Anonymizing the required email keeps its case-insensitive uniqueness and allows concurrent references to the account ID.
Lock order
FOR NO KEY UPDATE→ reread source series and select source and all same-group series date IDs → those huddlzFOR UPDATEby ID → update source → load and update its group’s template → reconcile later dates in that group → record source and scheduled startsFOR SHAREby ID → active group → resolve the confirmed recipient → expire matching expired pending invitations → insert invitationFOR SHAREby ID → active group → pending invitationFOR UPDATE→ record link opening and, if confirmed, lock any pending invitation already bound to the account and reconcile the offersFOR SHARE→ active group → pending invitationFOR UPDATE→ accept and grant membership if neededFOR SHAREwhen present → pending invitationFOR UPDATE→ status updateFOR SHAREby ID → groupFOR NO KEY UPDATE→ invitationFOR UPDATE→ when binding, lock any existing bound pending invitation, reconcile offers and announce when eligibleThe account lifecycle locks are transaction-scoped advisory locks acquired in key order. Ordinary group activity and departure take
FOR NO KEY UPDATEon the group. Archival and permanent deletion takeFOR UPDATE. A successful replacement invitation was traced through the group lock, the previous invitation’s expiry and the new insert.Series membership is set at creation. The standalone-to-series attachment branch and its concurrency test were removed after #724 closed that update path. A legacy huddl in another group can carry the same template ID and remains independently editable while the home group edits its series.
Account references
Evidence
Before: An upcoming members-only spot could survive a departure. A picture replacement or API key committed during deletion could survive cleanup. An open page could take a different route depending on which refresh arrived first.
After: Acceptance scenarios cover seat release, promotion, the former member’s recovery page and archived attendance through JSON:API and GraphQL. Separate database connections cover picture replacement, key creation, anonymization while the account ID is referenced, membership and invitation ordering, suspension attribution, group deletion and edits across a series. The edit-all tests verify the blocker with
pg_blocking_pidsand comparepg_stat_database.deadlocksbefore and after each case. They also cover a leave finishing while an edit waits for the lowest date ID, and a second connection locking a legacy huddl in another group during the edit.A two-tab photo refresh reproduced a checkout timeout on the test’s shared sandbox connection. The gallery scenarios now finish their refreshes before teardown, and the test sandbox allows for overlapping reads. The photo upload action uses the same group lock as main.
Merge Danger
Door: Two-way
Blast Radius: Attendance and account deletion