Repository navigation
p4: lean phase-3 GC authority - #770
mengmengmengqiang merged 12 commits into
Conversation
|
Thanks Rain. The phase-3 GC design is good: the ownership rule never declares an owner dead without proof, and the operator repair, retained 1. Please rebase onto the latest
|
|
Rebase is done on On the read-ahead bound: 141 is not introduced by this branch. Deferred per your note: lease/fence, cross-home merge and |
Rebase the p4 lean phase-3 engine delta onto the current layerfs_v2_0_0 release (87e46c6): the typed GC intent vocabulary, the SQLite and PostgreSQL GC schema and queries, admission with the machine incarnation and Sandbox generation ordering, the bounded place view, and the retained done audit; the store-service branch list records main's Branch id, and the merge-forms fixture is the patch's rebased-schema copy. Resolved against the rewritten release: the Branch list lives in history/listing.rs, the diagnostic mount reads sit on SqliteHandles, the contract records are split into contract/gc.rs and admission's session locks into admission/session.rs to keep the 999-line rule without waivers. Production LOC: 207,783 -> 208,969 (delta +1,186) core 40,989 -> 41,324 (+335) layerfs-history +335 engine 96,923 -> 97,774 (+851) layerfs-persistence +643, layerfs-store-service +208 control 59,546 -> 59,546 (0) api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree 97d6fc2 and committed tree 9e42d2f0894a719fd23558eb00f564b47b0cfd57
Rebase the p4 lean phase-3 control delta onto the current release. Store repair of mount admissions (preview/settle/release/settle_legacy/audit, archive export and prune) runs locally or through the Store owner's worker; the doctor reports store.mount_holders and store.gc_audit; machine.start stops and confirms the old worker, mints and records the ordered incarnation, launches the worker with it and reconciles the Stores on that machine; Sandbox close/remove write the durable retirement tombstone and end the mount intents; the worker server records and serves its incarnation. Resolved against the rewritten release: the removed sandbox/close.rs calls moved into lifecycle.rs and force.rs, the doctor target follows the 2.0 store_target/Checks framework instead of the removed dispatch/options modules, machine.start keeps the release's not_answering refusal and adds the incarnation/reconcile order, and the store_target doctor reports the mount holders and done audit from the shallow cut. Production LOC: 208,969 -> 210,375 (delta +1,406) core 41,324 -> 41,324 (0) engine 97,774 -> 97,774 (0) control 59,546 -> 60,952 (+1,406) layerfs-control +579, layerfs-home +14, layerfs-machine +62, layerfs-platform +10, layerfs-sandbox +79, layerfs-store +662 api 10,325 -> 10,325 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree 9e42d2f0894a719fd23558eb00f564b47b0cfd57 and committed tree bbae9ab47a7c257fd71542d59ccfb4337ef0fcfe
Add the explicit operator repair call and its worker route, the CLI worker's incarnation setting, the gc help and help-test updates, and the api test adjustments. The call table keeps the 2.0 families without a pinned count; the machine_no_start test keeps the release's answer that project.get reads from records on a stopped machine (the p4 refusal change is dropped) and sandbox.get's blocked state. Production LOC: 210,375 -> 210,437 (delta +62) core 41,324 -> 41,324 (0) engine 97,774 -> 97,774 (0) control 60,952 -> 60,952 (0) api 10,325 -> 10,387 (+62) layerfs-api +59, layerfs-cli +3 reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree bbae9ab47a7c257fd71542d59ccfb4337ef0fcfe and committed tree 0f86056ffbf4357016d5b19f9b87b4ec92703a3e
Rebase the p4 lean-phase-3 documentation onto the 2.0 guides: the GC specification and runbook, the mount-authority design supplement, the store/doctor/machine/SDK guides, the lean coordination/gap/verification records, and the product-boundary tool without the 999-line waivers (the two files are split by responsibility instead). Production LOC: 210,437 -> 210,437 (delta 0) core 41,324 -> 41,324 (0) engine 97,774 -> 97,774 (0) control 60,952 -> 60,952 (0) api 10,387 -> 10,387 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree 0f86056ffbf4357016d5b19f9b87b4ec92703a3e and committed tree 01facc5f12973d1a5aeb639cfda09a4064498bed
Port the p4 benchmark harness changes that exercise the lean GC Store: the compact-build prototype and the install-lane hazard, store, suite and WAL drivers. Production LOC: 210,437 -> 210,437 (delta 0) core 41,324 -> 41,324 (0) engine 97,774 -> 97,774 (0) control 60,952 -> 60,952 (0) api 10,387 -> 10,387 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree 01facc5f12973d1a5aeb639cfda09a4064498bed and committed tree fea9ca7a99c777da248e08f860bb97f81607dcff
…erge The shipped subset keeps the ordered place identity — machine_incarnation, sandbox_generation, their ordering rule and the machine-level retired Sandbox tombstone — and drops everything deferred to Ephemeral-AI-Lab#775: - the gc_intent lease_expires_ms and fence_token columns (both schemas and every intent select/insert), gc_intent_renew, GcIntent::renewed, gc_renew_lease/gc_release_fenced, the Bind heartbeat and the store-service renewal plumbing, the holder/diagnostic lease field and the fence tests; - the machines.<machine>.home cross-home discovery: OwnConnection.home, StoreRecord::machine_homes, PlaceView::from_homes/from_store and the merged/capped view. PlaceView now reads the caller's home alone; current/for_intent_with behavior is unchanged. The authority columns are now two, not four. gc_intent_release_done keeps its `state <> 'done'` guard. Production LOC: 210,437 -> 210,156 (delta -281) core 41,324 -> 41,292 (-32) layerfs-history -32 engine 97,774 -> 97,712 (-62) layerfs-persistence -39, layerfs-store-service -23 control 60,952 -> 60,765 (-187) layerfs-store -187 api 10,387 -> 10,387 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree fea9ca7a99c777da248e08f860bb97f81607dcff and committed tree f8fe2797089bed7fa6fa9f75803986d92e50b92d
- The jsonl `archive`/`--prune` export is removed (Ephemeral-AI-Lab#775): the control archive action and its file export, the service prune_done, the API `--prune` option, the worker `store.prune` operation, and the archive tests and help text. - `audit` is scoped to the named `<project> <branch>`, matching the actions above it: a new gc_intent_done_branch read filters on the recorded project and Branch names, so one Branch's retained rows never leak into another's page and a removed Branch's rows stay readable by the names they recorded. A two-branch isolation test covers it. - `list` is the read-only companion of preview: same typed holders, no retained done row. Every holder row now carries `safe` and `reason` from the admission verdict: a settled/uncertain row is safe to release, a live one is not. - Ordered place tokens compare by their millisecond only. Values minted in the same millisecond with different nonces are `Unordered`, never ordered by nonce; a test pins it. - The store_repair_live/worker and gc_calls tests follow the trimmed call surface, and the forgotten-sandbox doctor expectation follows the lean store.mount_holders check. Production LOC: 210,156 -> 210,021 (delta -135) core 41,292 -> 41,292 (0) engine 97,712 -> 97,712 (0) control 60,765 -> 60,631 (-134) layerfs-control -151, layerfs-store +17 api 10,387 -> 10,386 (-1) layerfs-api -1 reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree f8fe2797089bed7fa6fa9f75803986d92e50b92d and committed tree 0c8c4adeedef7965b8e3d759a5ae216dd81a9ba5
…-Lab#775) Label the deferred design (lease expiry/heartbeat/fencing, the cross-home place merge, and the jsonl archive export) in the GC specification, the mount-authority supplement and the runbook, keeping the rationale. Update the store.md repair section for the shipped actions (list, preview, settle, release, settle_legacy, Branch-scoped audit) and the two place columns. Production LOC: 210,021 -> 210,021 (delta 0) core 41,292 -> 41,292 (0) engine 97,712 -> 97,712 (0) control 60,631 -> 60,631 (0) api 10,386 -> 10,386 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree 0c8c4adeedef7965b8e3d759a5ae216dd81a9ba5 and committed tree e95fc00d87adff1fcc9e8e8cb717e31d3c4e5263
…ture The mounted_sequential_read test returns to the release's 64-demand bound: the p4 change raised it to 192, which would accept the 141-demand behaviour the maintainer flagged as a regression. The project_delete_worker caller_home drops the p4 machine-record seed; the base fixture already supplies the box machine, and the suite passes without it. Tests only. Production LOC: 210,021 -> 210,021 (delta 0) core 41,292 -> 41,292 (0) engine 97,712 -> 97,712 (0) control 60,631 -> 60,631 (0) api 10,386 -> 10,386 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree e95fc00d87adff1fcc9e8e8cb717e31d3c4e5263 and committed tree ab47f90653b0398b33299f08f1eb9f2fa35895fd
The conflict resolution left project.doctor twice in the project family; remove the duplicate. The calls_table expected project order follows the family's own order, and store_doctor expects the lean store.mount_holders and store.gc_audit rows. The merge-forms fixture is rebuilt on the trimmed two-column schema and its schema source/definition copied from a fresh Store of this build, so the root-form merge suites open it again. Tests and fixtures only. Production LOC: 210,021 -> 210,021 (delta 0) core 41,292 -> 41,292 (0) engine 97,712 -> 97,712 (0) control 60,631 -> 60,631 (0) api 10,386 -> 10,386 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree ab47f90653b0398b33299f08f1eb9f2fa35895fd and committed tree a93066a9b9dcd4f4e85bc81c02d603e8910b75c3
The daemon is the real mount path: it never sets the worker process-global incarnation. layerfs-sandbox now reads the Sandbox record's generation and the machine record's current incarnation under the same home the Store uses and sends both in the mount place; the placed bind records them on the mount intent. A private or place-unknown bind records no place authority and keeps the owner-token fallback. lease_expires_ms and fence_token stay absent: no heartbeat is connected yet. A retirement tombstone then proves the mount dead at admission, so branch.remove settles it without an operator. Tests: a placed bind records both values; a tombstoned Sandbox settles its mount; a private bind records none and still holds by its owner tokens; and an end-to-end daemon mount over its authenticated control channel reads the home records, records both values, and is settled by the tombstone. Production LOC: 214,004 -> 214,073 (delta +69) core 42,466 -> 42,466 (0) engine 98,213 -> 98,266 (+53) layerfs-bridge +46, layerfs-store-service +7 control 62,934 -> 62,950 (+16) layerfs-sandbox +16 api 10,391 -> 10,391 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree 5d1ca1c and committed tree e87ee9e
…pening it A base read that continues inside a window another request already fetched opens a second window in `Streams::follow`, so its tail is demanded and transferred again. Follow the same-root window that contains the start (`until > start`), taking the furthest end, instead. Measured on the Ephemeral-AI-Lab#779 prototype, with the 8 MiB READ_AHEAD and cache sizes unchanged: 141 -> 20 demands on SQLite and 27 on PostgreSQL; SQL statements 498 -> 314 (SQLite) and 284 -> 82 (PostgreSQL). References Ephemeral-AI-Lab#779, the base regression from FUSE out-of-order READ continuations. Production LOC: 214,073 -> 214,081 (delta +8) core 42,466 -> 42,466 (0) engine 98,266 -> 98,274 (+8) layerfs-workspace +8 control 62,950 -> 62,950 (0) api 10,391 -> 10,391 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd19) Method: tools/production_loc.py --detail on parent tree e87ee9e and committed tree 57ccf29
87890d7 to
ec99bf2
Compare
…p; review round 1 Formal tree from LayerFS Branch lean-gc-admission-src (12b0a54b + review round 1). Rebased onto layerfs_v2_0_0 2f9cb97 (PR Ephemeral-AI-Lab#770 merged); the old 0b4b20a/fe9b4d1a base is superseded. - ms-only Ordered.lt/comparePlace (same-ms different nonce = unordered) - authority-gated placeOf with the per-field PlaceView::record fallback - total Store.intents + EntriesSound support invariant - one CompactBarrier (no inv5 field), hypothesis restatements - close MountsActive + mount_intents::end, unmount release_or_mark - branch existence guard, preview evidence, 23 axiom receipts tools: check_lean_axioms requires Inv3/Inv4; test_production_loc carries the formal-tree-outside-product-LOC test.
fix(gc): make the merged lean GC authority (#770) never worse than the base
Problem
A mount is protected by a row in
gc_intent. While a Sandbox may still read a Branch, compaction must not delete that Branch's objects, so the row acts as a lock. The lock is released only when the system can prove the holder is gone.That proof was taken from the caller's process and boot identity: "is the process that mounted this Branch still alive on this machine, on the same boot?" It works only while the mounting machine is reachable and still running that boot.
It fails exactly when it matters most: the machine was restored from a snapshot or rebooted, the Sandbox was deleted while its mount row stayed behind, or the machine is offline. The check then cannot prove the holder is gone. Because "unprovable" is treated as "still live" — correctly, since reclaiming data a live mount is reading would corrupt it — the row stays live forever.
And the lock is not per-Branch: the compact barrier is Store-wide. One such row stops compaction for the whole Store, so objects no one can read anymore are never reclaimed, retired Branches and Sandboxes pile up, and the only way out is an operator settling or releasing the row by hand.
The design was conservative but incomplete: it had no durable way to prove death, and no audit of what an operator did when they cleared a row.
Shipped
The lean phase-3 design keeps the 2.0 schema change direct (2.0 is still in development; no compatibility migration) and adds no new tables. Authority lives in two columns on the existing
gc_intent:machine_incarnationandsandbox_generation.MachineRecord.incarnationandSandboxRecord.generationincrease strictly on machine restore / Sandbox create. Admission compares tokens: newer ⇒ Dead, older ⇒ Uncertain, equal or missing ⇒ Live. Death is concluded only from evidence that is provably newer; anything unprovable stays Live. There is no lease or fence in the shipped tree.machine/<machine>/sandbox-retired/<name>.json) records the retired generation, written before the Sandbox record is deleted, so a later admission can order a Sandbox whose row is already gone. A missing record and a missing tombstone are both "no proof", never death.releaseandpreviewwrite adonerow (owner columns cleared, the action/operator/op inevidence) instead of deleting the intent; the done-row read is bounded and Branch-scoped. Compact maps these rows withCopy::Done, so the audit survives compaction and the barrier has a well-defined end.store.repair_mount_holdersexposeslist,preview,settle,releaseandauditfor one Branch.previewchanges no live intent and writes its own retaineddonerow (action=preview,op=null, operator label inevidence).settlemarks an uncertain holder;releaseretains the row as the durable operator audit. There is no automatic release of an unprovable owner.store.mount_holdersandstore.gc_audit(plusproject.mount_holders) report the typed holder view and the bounded done audit from the Store owner's side.layerfs-sandboxreads the Sandbox record's generation and the machine record's current incarnation under the same home the Store uses, sends both in the mount place, andstore/bind.rsrecords both on the mount intent. A private or place-unknown bind records no place authority and keeps the owner-token fallback. The real-daemon end-to-end test islayerfs-control/tests/mount_place_authority.rs.Streams::follownow follows a same-root window that contains the read start (until > start, taking the furthest end) instead of opening a second window and re-demanding its tail. This fixes the base regression fromd19d98f138(FUSE out-of-order READ continuations).mounted_sequential_readis now expected to pass, and its bound stays 64 demands. Measured on the Sequential read: 141 Store demands for 64 MiB on base (read-ahead re-opens windows under concurrent FUSE reads) #779 prototype with the 8 MiBREAD_AHEADand cache sizes unchanged: 141 → 20 demands on SQLite, 141 → 27 on PostgreSQL; SQL statements 498 → 314 on SQLite and 284 → 82 on PostgreSQL.Deferred
Tracked in #775: lease/fence renewal (no producer/heartbeat yet, so a row is not renewed and release is unfenced), the cross-home
PlaceViewmerge (machines.<m>.homehas no public writer;PlaceViewreads the caller's home alone), and durablearchive --prune(audit is Branch-scoped and bounded; no jsonl archive). The Lean formalization track is #769.Rebase status
Rebased onto the current
layerfs_v2_0_0releasefe9b4d1a3c9bdc01265d7a959c40ab102d6a47a5; the branch has 12 ordinary commits, all authored byrain <mengmengmengqiang@gmail.com>.git diff --shortstat up/release HEAD= 173 files changed, 10,362 insertions(+), 1,686 deletions(-).The 8 conflicts reported by
git merge-treewere resolved with current base code winning and p4 semantics carried into the 2.0 shapes:api/crates/layerfs-api/src/lib.rs,api/crates/layerfs-cli/src/worker.rs: the 2.0 worker surface keepsprepare_networkand adds the incarnation-awareserve_with_incarnation; the worker binary passes itsLAYERFS_WORKER_INCARNATION.control/crates/layerfs-platform/src/platforms/docker/power.rs: the 2.0entry(host_network)shape, with the worker incarnation environment variable added.control/crates/layerfs-sandbox/src/lifecycle.rs: the 2.0 handed-intent comment plus the retirement tombstone write.docs/architecture/engine/store/postgresql.md,docs/architecture/control/stores-and-projects/sqlite-and-postgresql.md: 2.0 URL/schema text, with the shipped table counts and no cross-home claim.engine/crates/layerfs-persistence/src/backend/postgresql/schema.rs,records.rs,diagnostic/postgresql_contract_expected.rs: 2.0 schema version 3 and PostgreSQL v2 refusal, keeping the SQLite v2 → v3 conversion refusal (SchemaVersion2) and the p4 GC schema.The rebase also removed a previous-rebase artifact that had moved
placefrom the 2.0WorkspaceApiback ontoControl; the branch now keepsWorkspaceApi.placeand the authority commit'sMountPlacewiring sits on top of it.Verification
On this head (
ec99bf29c2):cargo check --offline --workspace --all-targets: exit 0.TMPDIRon ext4 and PostgreSQL unset:layerfs-persistence --test gc_conversion: 3 passed, 0 failed.layerfs-persistence --test sqlite_compact_done: 2 passed, 0 failed.layerfs-store-service --test admission: 10 passed, 0 failed.layerfs-control --test store_repair_live: 2 passed, 0 failed.layerfs-control --test mount_place_authority: 1 passed, 0 failed.layerfs-cli --test gc: 5 passed, 0 failed.layerfs-api --test gc_calls: 11 passed, 0 failed.layerfs-api --test calls_table: 26 passed, 0 failed.layerfs-daemon --test mount_holders: 2 passed, 0 failed.cargo test -p layerfs-workspace: 189 passed, 0 failed across its suites (includingread_ahead4/4).Environment limits:
LAYERFS_TEST_POSTGRES_URLunset): PostgreSQL-live suites were not run.repair_postgresqlstill cannot pass on PostgreSQL as written (its setup callsadd_project, which is SQLite-only); it needs theproject.initsetup path./dev/fuse, so the mount andmounted_sequential_readtests could not run here. The read-ahead change is covered by thelayerfs-workspacesuites and by the Sequential read: 141 Store demands for 64 MiB on base (read-ahead re-opens windows under concurrent FUSE reads) #779 prototype measurement above.Earlier runs in a privileged Linux container with a real
/dev/fuse(pre-rebase head; kept for reference, not re-run here): FUSE mount binaries 12/12 (kernel_application1,kernel_mount_routes2,observed_application8,r5_1_actual_daemon_commit1);install_directory4/4;kernel_guard5/5;closed_streams3/3;machine_list_live1/1;project_stats4/4,store_stats2/2,saved_continuation2/2 on cleanlayerfsschemas.Known limitations
PlaceViewmerge is deferred to GC authority: deferred lease/fence, cross-home merge and durable archive (needs producers) #775:PlaceViewreads the caller's home alone, andmachines.<m>.homehas no public writer yet.archive --pruneis deferred to GC authority: deferred lease/fence, cross-home merge and durable archive (needs producers) #775:auditis Branch-scoped and bounded, and the retained done rows stay ingc_intent.repair_postgresql, compact/diagnostic/doctor suites) were not run here because no PostgreSQL server is available.project_statsandstore_statscannot share one PostgreSQL database: onelayerfsschema is one Store, so the second binary'sproject.initmeets the first's projectp. They pass alone on a clean schema; the CI lanes run targets separately.settle,release) was run for this change; the SQLite operator paths are covered bystore_repair_liveand the API suites.What this fixes for an already-stuck Store (upgrade note)
store.repair_mount_holders list/previewshows the holders withsafe/reason; thensettle(evidence-backed) orrelease(explicit operator escape hatch) the rows known to be dead.auditkeeps the retaineddonerows.store.compact. Per-generation pinning (a stuck mount blocking only its own generation) is the follow-up design (B3), not part of this PR.The live Store is operator-owned; this PR does not touch it.