fix: sync every created lifecycle ancestor from cleaned paths

This commit is contained in:
pingqiu committed 2026-11-22 10:44:01 -08:00
1 parent f865a8e21f
commit aaedc61855
5 files changed
+78 -12

No files matched your search

+25 -3
View File
@@ -78,12 +78,34 @@ func OpenNodeInventoryStore(dir string) (*NodeInventoryStore, error) {
if dir == "" {
return nil, fmt.Errorf("%w: empty dir", ErrInvalidNodeRegistration)
}
dir = filepath.Clean(dir)
ancestor := dir
for {
if _, err := os.Stat(ancestor); err == nil {
break
} else if !errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err)
}
parent := filepath.Dir(ancestor)
if parent == ancestor {
return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir)
}
ancestor = parent
}
if err := os.MkdirAll(dir, 0o755); err != nil {
return nil, fmt.Errorf("lifecycle: mkdir node inventory %q: %w", dir, err)
}
// INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry.
if err := syncBindingParent(filepath.Dir(dir)); err != nil {
return nil, fmt.Errorf("lifecycle: sync store parent: %w", err)
// INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent,
// deepest first. Existing-store retries still sync the store's parent.
for current := dir; ; {
parent := filepath.Dir(current)
if err := syncBindingParent(parent); err != nil {
return nil, fmt.Errorf("lifecycle: sync store parent: %w", err)
}
if current == ancestor || parent == ancestor {
break
}
current = parent
}
s := &NodeInventoryStore{
@@ -49,12 +49,34 @@ func OpenPlacementIntentStore(dir string) (*PlacementIntentStore, error) {
if dir == "" {
return nil, fmt.Errorf("%w: empty dir", ErrInvalidVolumeSpec)
}
dir = filepath.Clean(dir)
ancestor := dir
for {
if _, err := os.Stat(ancestor); err == nil {
break
} else if !errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err)
}
parent := filepath.Dir(ancestor)
if parent == ancestor {
return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir)
}
ancestor = parent
}
if err := os.MkdirAll(dir, 0o755); err != nil {
return nil, fmt.Errorf("lifecycle: mkdir placement intent %q: %w", dir, err)
}
// INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry.
if err := syncBindingParent(filepath.Dir(dir)); err != nil {
return nil, fmt.Errorf("lifecycle: sync store parent: %w", err)
// INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent,
// deepest first. Existing-store retries still sync the store's parent.
for current := dir; ; {
parent := filepath.Dir(current)
if err := syncBindingParent(parent); err != nil {
return nil, fmt.Errorf("lifecycle: sync store parent: %w", err)
}
if current == ancestor || parent == ancestor {
break
}
current = parent
}
s := &PlacementIntentStore{
+25 -3
View File
@@ -90,12 +90,34 @@ func OpenFileStore(dir string) (*FileStore, error) {
if dir == "" {
return nil, fmt.Errorf("%w: empty dir", ErrInvalidVolumeSpec)
}
dir = filepath.Clean(dir)
ancestor := dir
for {
if _, err := os.Stat(ancestor); err == nil {
break
} else if !errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("lifecycle: stat store ancestor: %w", err)
}
parent := filepath.Dir(ancestor)
if parent == ancestor {
return nil, fmt.Errorf("lifecycle: no existing store ancestor for %q", dir)
}
ancestor = parent
}
if err := os.MkdirAll(dir, 0o755); err != nil {
return nil, fmt.Errorf("lifecycle: mkdir %q: %w", dir, err)
}
// INV-LIFECYCLE-STORE-DURABLE-001: persist a newly created store entry.
if err := syncBindingParent(filepath.Dir(dir)); err != nil {
return nil, fmt.Errorf("lifecycle: sync store parent: %w", err)
// INV-LIFECYCLE-STORE-DURABLE-001: sync every new directory's parent,
// deepest first. Existing-store retries still sync the store's parent.
for current := dir; ; {
parent := filepath.Dir(current)
if err := syncBindingParent(parent); err != nil {
return nil, fmt.Errorf("lifecycle: sync store parent: %w", err)
}
if current == ancestor || parent == ancestor {
break
}
current = parent
}
s := &FileStore{
@@ -38,8 +38,8 @@ func TestLifecycleStoreParentSyncChild(t *testing.T) {
dir := filepath.Join(root, "store")
want := []string{root}
if os.Getenv("LIFECYCLE_PARENT_SHAPE") == "nested" {
dir = filepath.Join(root, "new-parent", "store")
want = []string{filepath.Dir(dir), root}
dir = filepath.Join(root, "new-parent", "deeper", "store")
want = []string{filepath.Dir(dir), filepath.Join(root, "new-parent"), root}
} else {
dir += string(os.PathSeparator)
}
+1 -1
View File
@@ -650,7 +650,7 @@ Notes:
| `INV-WS-LEASE-HORIZON-MONO-001` | Within one lease the published horizon never decreases: an extension writes a new horizon only when it is greater than the current one. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `extendWorkspaceLease`; `core/authority/workspace.go` `persistWorkspaceLocked` | `TestWorkspaceExtenderHeldOrdersSameVolumeWriters`, `TestWorkspaceLeaseConcurrentRenewalsWritersExtendersClose` (`core/authority/workspace_lease_horizon_test.go`) | — | ACTIVE |
| `INV-WS-RENEW-NONBLOCKING-001` | Live renewals take only the leaf lease lock and lock-free lifecycle snapshots; they never wait on publisher/store locks. First grants and expired re-grants persist synchronously; an expired re-grant refuses immediately if the publisher lock is busy. | M2 Granted → Granted | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`; `core/host/master/workspace_service.go` `workspaceVolumeForRenewal` ; `core/lifecycle/placement_intent.go` `GetPlacementSnapshot`; `core/host/master/workspace_service.go` `RenewWorkspaceLease`; `core/lifecycle/node_inventory.go` `GetNodeSnapshot` (the holder host check) | `TestWorkspaceRenewalDoesNotWaitForSlowStore`, `TestWorkspaceConcurrentRenewalsDoNotSerializeOnStore`, `TestWorkspaceRenewalDoesNotWaitForUnrelatedHeldWrite` (`core/authority/workspace_renewal_slowstore_test.go`); `TestWorkspaceExtenderAdmittedBeforeCloseDoesNotWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceLeaseGuardSurvivesSlowAuthorityStore`, `TestWorkspaceRenewalRPCDoesNotWaitForHeldReservationWrite` (`core/host/master/workspace_renewal_slowstore_test.go`) ; `TestPlacementSnapshotDoesNotWaitForWriter`, `TestPlacementSnapshotFailedCommitStaysCommitted` (`core/lifecycle/placement_snapshot_test.go`); `TestNodeSnapshotDoesNotWaitForARegistrationWrite` (`core/lifecycle/node_snapshot_test.go`); `TestLiveRenewalDoesNotWaitForAHeldRegistrationWrite` (`core/host/master/server_host_identity_test.go`) | — | ACTIVE |
| `INV-LIFECYCLE-SNAPSHOT-001` | The Volumes and deletion-reservation snapshots read by the renewal path equal the store records after every change of the records, including load, delete and a protective reservation kept in memory on an unknown write outcome; a published snapshot is never mutated. | M2 Bound → Deleting (renewal reads) | `core/lifecycle/store.go` `publishLocked`, `GetVolumeSnapshot`; `core/lifecycle/deletion_reservations.go` `publishLocked`, `ReservedSnapshot` | `TestDeletionReservationSnapshotFollowsRecords`, `TestFileStoreSnapshotFollowsRecords`, `TestLifecycleSnapshotReadsDoNotTakeStoreMutex`, `TestLifecycleSnapshotConcurrentWriters` (`core/lifecycle/renewal_snapshot_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`) | — | ACTIVE |
| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`) | — | ACTIVE |
| `INV-LIFECYCLE-STORE-DURABLE-001` | Node registration, volume record and placement-intent puts/replacements are atomic and durable: after a crash the record file is the complete old or the complete new record; a put that returned nil has fsynced the file and its directory. | M2 lifecycle record publication | `core/lifecycle/node_inventory.go`, `store.go`, `placement_intent.go` `putLocked` (temp + Sync, rename over the old file, `syncBindingParent`) | `TestNodeInventoryCrashKeepsCompleteRegistration` (`core/lifecycle/node_inventory_crash_test.go`); `TestFileStoreCrashKeepsCompleteRecord`, `TestPlacementStoreCrashKeepsCompleteRecord`, `TestLifecyclePutSyncOrderAndFailure` (`core/lifecycle/store_crash_test.go`); `TestLifecycleStoreParentSync` (`core/lifecycle/store_parent_sync_test.go`) | — | ACTIVE |
| `INV-VOL-ID-NO-REUSE-001` | A deleted volume id is never created or attached again. | M2 Deleting; M6 purging → deleted | `core/host/master/services.go` `MarkVolumeDeleting`; `core/frontend/chunkstore/catalog.go` `EnsureVolume` | `TestMarkVolumeDeleting_ReservesUnknownIdsAndSurvivesDeleteAndRestart` (`core/host/master/volume_deleting_test.go`); `TestCatalog_DeleteVolumeTombstonesAndRefusesReuse` (`core/frontend/chunkstore/volume_delete_test.go`) | `ChunkLifecycleFixed` `NoIdReuse` | ACTIVE |
| `INV-MASTER-JOURNAL-ISOLATION-001` | Under strict journal isolation, blockmaster gives no new work to a node whose durable root shares the authority store's file system: it refuses that node's heartbeat while it serves no volume, a new placement on it and a move onto it; work the node already has is kept. | M2 workspace move: Acked or Expired → (move refused, nothing written); workspace placement admission; node heartbeat | `core/host/master/journal_isolation.go` `refuseColocatedHeartbeat`, `colocatedTargetRefused`, `reconcilePlacements`, `nodeServesVolumes`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/host/master/workspace_binding.go` `PlaceWorkspace` | `TestColocatedNodeIsAlarmedButAcceptedByDefault`, `TestStrictRefusesColocatedNodeWithoutVolumes`, `TestStrictAcceptsColocatedNodeThatAlreadyServes`, `TestStrictRefusesPlacementAndMoveOntoColocatedNode`, `TestStrictProductLoopSkipsColocatedNodeForNewPlacement` (`core/host/master/journal_isolation_test.go`); `TestStrictReplaysAnIssuedMoveToANowColocatedTarget`, `TestStrictKeepsAnIdempotentPlacementOnANowColocatedNode` (`core/host/master/journal_isolation_fold_test.go`) | — | ACTIVE |
| `INV-SEC-CONTROL-BIND-001` | blockmaster's unauthenticated control listeners (--listen, and the runtime HTTP listener when enabled) bind only loopback unless --insecure-external-bind is given; a non-loopback address is refused at startup. | AUTHORITY: control API reachability | `core/host/master/journal_isolation.go` `ValidateControlListen`; `cmd/blockmaster/main.go` `parseFlags` | `TestParseFlags_ControlListenersNeedInsecureExternalBind`, `TestManifests_ExternalBlockmasterBindCarriesTheOptIn` (`cmd/blockmaster/external_bind_test.go`) | — (no state machine; the flag test is the proof form) | ACTIVE |