Repository navigation
fix(api): every exec session gets exactly one recorded closing (closes #489) - #511
Merged
Merged
Conversation
…#489) The end of a session was written once; a failure was logged and forgotten, and a process that stopped left its sessions without an end. The end is now tried again with a growing delay, looking first for an earlier write whose answer was lost. A check queued with the opening, in the same transaction, records the session interrupted when no closing exists once it must have ended, and the checks of a stopped process run at the next start. Signed-off-by: samuel mbabhazi <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
What changed
ExecSessionRegistry: the connections are still released at once. The end's audit write is now tried again when it fails, with a delay that doubles from 1 s to 1 min, for about 15 minutes.ExecSessionChecks(fleet infrastructure), a pg-boss queue namedexec-session-check:ExecSessions.openqueues the session's check in the transaction that recordsexec.session.opened, for 5 minutes afterendsAt.exec.session.endedorexec.session.interruptedevent exists. Otherwise it recordsexec.session.interrupted: system actor, the session's person,reason: unknown.main.tsstarts it before the API listens, and its startup sweep runs the queued checks at once. Sessions live in one API process only, so those of the stopped process are gone.AuditModuleexportsAUDIT_EVENT_READER, andFleetModuleimports it. There is no cycle: the audit module does not depend on fleet.Why
Closes #489.
ExecSessionRegistry.endedremoved the session, tried the audit write once, and forgot it on failure. A process that stopped left its sessions with an opening and no end. Recovery of the database retried nothing.How it was tested
exec-relay.spec.ts: the store fails once, then commits while the answer is lost. The relay is released at once, the write is tried 3 times, and exactly oneexec.session.endedis recorded. This test failed on the old code.exec-sessions.spec.ts: an opening queues its check after its action and its audit event, with the session'sendsAt.exec-session-checks.integration.spec.ts(real PostgreSQL and pg-boss):exec.session.interrupted. Run again, it finds the closing and records nothing.exec.session.endedexists is left as it is.api:lintandapi:typecheck. The integration suite passes locally except the known PostgreSQL 18 and Docker-only files.Security considerations
The queue's job data holds identifiers only (organization, session, person), never what the session ran or showed. The interrupted record claims nothing beyond "unknown", and the closing check reads the organization's own audit events under its row security. Transport cleanup does not wait for the audit store.