Skip to content

Close recorder database sessions before finalization - #125

Merged
abrichr merged 1 commit into
mainfrom
codex/capture-finalization-session-lifecycle
Aug 28, 2026
Merged

Close recorder database sessions before finalization#125
abrichr merged 1 commit into
mainfrom
codex/capture-finalization-session-lifecycle

Conversation

@abrichr

@abrichr abrichr commented Aug 28, 2026

Copy link
Copy Markdown
Member

Why

Production qualification run 33207241071 failed on hosted macOS after a live recorder trial completed. finalize_capture_database() raised sqlite3.OperationalError: database is locked while changing the finished database from WAL back to the rollback journal.

create_recording() left its setup SQLAlchemy session attached to the returned Recording. Its pooled connection could remain open until cyclic garbage collection ran, so finalization could race that connection.

What changed

create_recording() now detaches the returned model, closes the setup session, and disposes its engine before returning. Recorder writer functions also close their sessions and dispose the session engines in finally blocks. This doesn't change persistence or lock-retry behavior. It releases recorder-owned connections before database finalization.

The regression test creates a recording, finalizes it immediately without forcing garbage collection, and verifies that neither recording.db-wal nor recording.db-shm remains.

Verification

Candidate: 9519e160c1b410573e19ad03b77a1f97260c0b15

  • 704 passed, 2 skipped, and 13 deselected in the full non-slow suite
  • 24 passed in the focused database and writer suite
  • Ruff and the v1.3.0 changelog check passed
  • The 1.3.0 wheel and source archive passed package, license, and source-policy checks
  • The wheel passed an isolated macOS Python 3.12 install, import, CLI, and uninstall lifecycle

@abrichr
abrichr merged commit 0c9661a into main Aug 28, 2026
14 checks passed
@abrichr
abrichr deleted the codex/capture-finalization-session-lifecycle branch August 28, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant