Repository navigation
fix(objectql, plugin-audit): bound a held session lock's probe, unlock and close so a stalled connection cannot hang the sealer or --apply - #35779
Conversation
… a stalled connection cannot hang its holder Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7 Co-authored-by: Claude <noreply@anthropic.com>
…a lost lock, and finish and the sealer pass end Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibwJEh7hMPPvagWM1g7 Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check7 anchor(s) derived from 2 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 30 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b703611af19194202f5479d5cc14add49631af75 && git checkout b703611af19194202f5479d5cc14add49631af75
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin d1ebe86dd3c2ec380de7c2c8607306c8e4bb9b73 6262e609ac8a6f3d09f01ba424582b6c561297a2 && git checkout -B drift-repro d1ebe86dd3c2ec380de7c2c8607306c8e4bb9b73 && git merge --no-ff 6262e609ac8a6f3d09f01ba424582b6c561297a2
node scripts/docs-audit/affected-docs.mjs --json d1ebe86dd3c2ec380de7c2c8607306c8e4bb9b73 |
|
repo:objectstack#7 · os-tesla · session_01L9qibyQBB3KuDoNobNq9LH Seat checkL1: ACCEPT (L1-a, for area d7-B) at head Shape and declarations
Code (
|
|
repo:objectstack#7 · os-tesla · session_01L9qibwJEh7hMPPvagWM1g7 Landing · 2026-11-20T07:36Z · head
State: |
Requested by Tesla · project thread
Fixes #33932
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
The card's acceptance, verbatim:
packages/objectql/src/database-session-lock.ts: a held lock's three finishing steps each race a 10 s bound (DATABASE_SESSION_LOCK_ANSWER_MS, exported from the module only, not from the package entry):isHeld(): aselect 1not answered in time readsfalse(lost), and the session is marked stalled, so it is never probed again.release(): the unlock statement is bounded. After a stalled probe no unlock is sent at all: the connection is closed, which releases the lock.destroyRawConnection): bounded, for every caller of the shared close.vi.getTimerCount()is 0 after a live probe and release).packages/plugins/plugin-audit/src/audit-seal/seal-lock.ts: docs onfinish(), and the lost-lock line now reads(its database session ended, or stopped answering). The CLI path is unchanged.underAuditSealLockreturns the line aslostLock, and eachos migrate audit-*command prints it withprintErrorand callsthis.exit(1).audit-redaction-seal.contract.test.tsalready pins that exit.isHeld()(inlapsed()before each checkpoint) andrelease()(in itsfinally), so both are bounded now.@objectstack/objectqland@objectstack/plugin-audit, bothpatch.Declared change to the schema-migration lock (card item 3). The bound lives in the shared module, so
acquireSchemaMigrationLock'srelease()is bounded too. Its statements are byte-identical, and the existingschema-migration-lock.test.tsstatement pins pass unchanged. A live session behaves as before. The only change: a release on a session that has stopped answering returns after the bound instead of hangingos migrate applyor the boot's schema sync. The advisory lock then stays with that database session until the connection dies, as it would if the process had been killed. The migration lock never callsisHeld().I did not make the bound opt-in from the seal-lock caller. That needs a new field on the exported
DatabaseSessionLockRunOptions(or onDatabaseSessionLock), which widens@objectstack/objectql's published surface and would makeClause-②yes (widening), against the claim. Bounding every holder keeps every exported signature unchanged.Tests
Premise re-measured with a never-answering fake, before the fix (origin/main ca4ec2a)
The new
database-session-lock.test.tsblock, run against the unfixed module: 7 failed | 19 passed. The 6 stall pins each read'still waiting'after the bound (probe, unlock and close never settle). The 7th failure is the constant pin, which readsundefined. The live-path pin passed.New pins:
packages/objectql/src/database-session-lock.test.ts, new describea stalled session never hangs its holder, on fake timers:falseat the bound, never re-sent;packages/plugins/plugin-audit/src/audit-seal/audit-seal-lock.test.ts, new describea stalled connection cannot hang the hold's finish or a sealer pass:finish()on a stalled session resolves{ lost: true }with the line namingos audit verify, and no unlock is sent;the audit seal lock on the database of 'sys_audit_log' lapsed.Results, all on head 6262e60:
pnpm --filter @objectstack/objectql test: Test Files 619 passed (619), Tests 13986 passed (13986). Lock VERDICT command-exit 0.pnpm --filter @objectstack/plugin-audit test: Test Files 103 passed (103), Tests 1726 passed (1726). Lock VERDICT command-exit 0.pnpm --filter @objectstack/objectql typecheckandpnpm --filter @objectstack/plugin-audit typecheck: both exit 0.check:test-typecheckOK on both.Acceptance notes
stream.destroy(), mysql2destroy()) that knex does not expose ondestroyRawConnection. On the--applypath the command exits through oclif'sprocess.exit, so the process does not linger.heldAmong, the wait) is not in this card.Verification
Ablations: one per leg, each with on-disk proof (scripts/ablation-replace.mjs) and restore proof (blob == HEAD, git diff HEAD empty)
objectql suite (imports
src/, so no build is in the loop):withinAnswerTime(run('select 1 as held'))changed to the barerun(...). 3 failed: both probe pins, plus the stalled-probe-then-release pin.destroyRawConnection. 2 failed: the close pin and the stalled-probe-then-release pin.exit 99(queue-timeout) and measured nothing. Both were re-run.plugin-audit suite (resolves
@objectstack/objectqlthrough itsdist/, aKNOWN_UNALIASED_TEST_IMPORTSpair):Promise.race([step, stalled])changed to the bare step. objectql rebuilt;ablation-dist-preflightconfirmed the marker present in 2 built files. 2 failed: both new seal-lock pins.--absentpreflight: marker absent from all 14 built files. Both suites green again.Derived gate families (dispatch-gates --commands, narrowed to this diff), head 6262e60
check:dual-build-cjs-loadsandcheck:i18n. Neither reads a file this diff changes, and CI runs both on a full build.dispatch-gates --ranreconciliation: 69 accounted, 67 run, 2 NOT-MEASURED derived from the recorded exit 3, 0 unrun.overlap-checkagainst origin/main d1ebe86: merges cleanly.Two-minute check:
pnpm --filter @objectstack/objectql exec vitest run src/database-session-lock.test.ts. Expect 26 passed. Then deletewithinAnswerTime(...)aroundselect 1 as heldand re-run: the two probe pins and the stalled-probe-then-release pin go red.Read first:
database-session-lock.ts, theheld()hunk: thestalledflag and the skipped unlock.database-session-lock.ts,withinAnswerTime: its timer is cleared infinally.audit-seal-lock.test.ts, the sealer-pass pin.Generated by Claude Code