Broadcast a session's QUIT once when its clients leave together (closes #154)
check / check (push) Waiting to run

Logout deleted the client, counted the session's clients and ran
BroadcastQuit as separate statements, and BroadcastQuit read the peers,
parted, deleted empty channels and deleted the session separately too.
Two logouts or QUITs of one session at once both sent its QUIT, and a
JOIN landing between a part and the channel's deletion got into a +k
channel without the key.

db.QuitSession now does all of that in one transaction, parting each
channel as PartChannelAndDeleteIfEmpty does, and stores and queues the
QUIT in it only when it deleted the session, so the QUIT is queued
before the nick is free. db.LogoutClient deletes the client and counts
the rest in the same transaction.

Model: opus-5-5
This commit is contained in:
2026-10-20 23:24:51 +00:00
committed by sneak
parent bbdf3a70af
commit 0ca6ae6c2f
7 changed files with 1110 additions and 189 deletions
+7 -4
View File
@@ -2569,10 +2569,13 @@ issues) and simpler than UUIDs (integer comparison vs. string comparison).
- **Sessions**: Both anonymous and password-protected sessions are deleted on
`QUIT` or when the last client logs out (`POST /api/v1/logout` with no
remaining clients triggers session cleanup). There is no distinction between
session types in the cleanup path — `handleQuit` and `cleanupUser` both call
`DeleteSession` unconditionally. Idle clients are automatically removed after
`SESSION_IDLE_TIMEOUT` (default 30 days) without an authenticated HTTP API
request or, on the IRC listener, a command — the server runs a background
session types in the cleanup path: the session is parted from its channels,
deleted, and its QUIT queued to its channel peers in one database transaction,
so when several QUITs or logouts end one session at once only the one that
deletes it broadcasts QUIT, and whatever a new holder of the nick sends
reaches those peers after the QUIT. Idle clients are automatically removed
after `SESSION_IDLE_TIMEOUT` (default 30 days) without an authenticated HTTP
API request or, on the IRC listener, a command — the server runs a background
cleanup loop that, for a session left with no clients, parts the user from all
channels, broadcasts QUIT, and releases the nick.
- **Clients**: Individual client auth cookies are invalidated on