Skip to content

Release lease and SQLite descriptors when a project closes; recover the heartbeat after a malformed read - #1012

Queued
aft-alfonso[bot] wants to merge 4 commits into
mainfrom
land/lease-release-descriptors
Queued

aft-alfonso[bot] wants to merge 4 commits into
mainfrom
land/lease-release-descriptors

Conversation

@aft-alfonso

@aft-alfonso aft-alfonso Bot commented Oct 26, 2026

Copy link
Copy Markdown

Fixes the descriptor census failure on main (subc::tool_result_tests::tool_result_fixtures_release_descriptors, which knocked out the #984 merge group) and a heartbeat regression from #988.

  • A detached LSP applicability walk held a Config snapshot that carried the project's cache and storage leases, so .aft-in-use.lock, retention/daemon-use.lock and two directory handles stayed open after the project closed. The walk now gets a snapshot without runtime leases. (Predates land: lease-heartbeat-open-handles #988: b684549, ef9e9d4.)
  • The standing-roots worker detached its join handle, so its startup reconciliation's SQLite connection outlived module teardown. Teardown now stops queued passes and joins current work, releasing the database through its owning connection. (Predates land: lease-heartbeat-open-handles #988: cc427d9, 4796341.)
  • From land: lease-heartbeat-open-handles #988 (3f83937): a beat that read a malformed lock file once turned the error terminal. It now retires the malformed handle and the next beat reopens the live path.

Tests: applicability_walk_does_not_retain_released_storage_leases, released_lease_closes_all_descriptors_synchronously, malformed_beat_reopens_atomic_replacement_on_next_beat, standing_worker_drop_waits_for_owned_sqlite_connection. The census test passed 20 of 20 runs on Linux after the fixes.

ualtinok and others added 4 commits October 27, 2026 00:10
Read-only applicability workers do not need storage ownership leases. Remove those runtime references from their detached configuration snapshots so releasing the last context closes both lock files and pinned directories synchronously.

Return malformed lease reads as transient errors after retiring the kept descriptor. The next scheduled beat reopens the live path, without a production-length retry sleep or a false NotOwner timeout. Healthy beats still reuse descriptors.

Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
(cherry picked from commit 9dc3819128fb1664fe28285693dc2adce8a197b5)
Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
(cherry picked from commit 36385a361b06af3bb56fd6296c4e21dd99394134)
Standing startup reconciliation opens aft.db on its worker. Dropping only the request sender detached a pass that could retain the owning SQLite connection beyond module-loop teardown and fixture storage deletion. Disconnect requests, discard queued passes, and join the active pass so the connection closes through its owner.

This pre-existing lifetime began with detached StandingWorker in cc427d9 and startup reconciliation offload in 4796341, before #988. Runtime tracing established the opener; no separate DB, WAL, SHM, or journal descriptor is opened or inspected for cleanup.

Add a controlled connection-owning worker regression and Linux descriptor census. Final linux,2c checks passed: 61 fs_lock, 3 applicability, 20 standing tests, plus 20/20 exact fixture-census repetitions. Windows tests cross-compile with warnings denied. Native macOS passes 59 fs_lock tests and the SQLite-owner regression; lease acquisition setup is denied in this environment, including the unchanged pre-existing lease test.

Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
(cherry picked from commit 5734383baf74b9622c0cc6c1524950133b571030)
Co-authored-by: alfonso-aft <289616620+alfonso-aft@users.noreply.github.com>
@ualtinok
ualtinok added this pull request to the merge queue Oct 26, 2026
Any commits made after this event will not be merged.
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