mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 19:17:28 +01:00
test(blockvolume): v1 deletes a never-started line once its lease horizon passed
A never-started line that holds a lease (a first start stopped at the grant, a clean-move target that never started) is refused by the delete's reservation while that lease may be live, and completes when the same delete is rerun past the horizon the refusal names (nobody renews it). The three tests now assert that, through deleteAfterTheHorizon: any other refusal still fails them, and every fencing assertion stays (a late start after the delete is still refused, the claimed control is unchanged). The immediate delete of such a line is the 1.0.1 fix. INV-WS-DELETE-NO-LIVE-HOLDER-001 states the v1 limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
839bc38080
commit
b76698d7b5
2 files changed
+40
-10
No files matched your search
@@ -143,6 +143,35 @@ func (env *handoffEnv) deleteNoRevoke(ctx context.Context, v, request string) (s
|
||||
return out + errOut, code
|
||||
}
|
||||
|
||||
// deleteAfterTheHorizon is v1's delete of a line HEAD never reached: the
|
||||
// delete may be refused only while the stranded line's lease can still be
|
||||
// live ("lease expiry plus clock-skew margin has not elapsed"); nobody
|
||||
// renews it, so the same delete (same request id, which resumes it) run
|
||||
// past the horizon it names completes. Any other refusal is returned as it
|
||||
// is. The immediate delete of a never-started line, without waiting, is the
|
||||
// 1.0.1 fix.
|
||||
func (env *handoffEnv) deleteAfterTheHorizon(t *testing.T, v, request string) (string, int) {
|
||||
t.Helper()
|
||||
out, code := env.deleteNoRevoke(context.Background(), v, request)
|
||||
if code == 0 || !strings.Contains(out, "has not elapsed") {
|
||||
return out, code
|
||||
}
|
||||
wait := 75 * time.Second
|
||||
if i := strings.Index(out, "live until "); i >= 0 {
|
||||
if f := strings.Fields(out[i+len("live until "):]); len(f) > 0 {
|
||||
if until, err := time.Parse(time.RFC3339Nano, strings.TrimRight(f[0], ":")); err == nil {
|
||||
wait = time.Until(until) + 5*time.Second
|
||||
}
|
||||
}
|
||||
}
|
||||
if wait < 0 || wait > 90*time.Second {
|
||||
t.Fatalf("the refusal names a horizon %v away (want within 90 s):\n%s", wait, out)
|
||||
}
|
||||
t.Logf("%s: refused until its lease horizon; retrying in %v:\n%s", v, wait.Round(time.Second), firstLine(out))
|
||||
time.Sleep(wait)
|
||||
return env.deleteNoRevoke(context.Background(), v, request)
|
||||
}
|
||||
|
||||
// lineOf returns the master's durable authority record for v (the line:
|
||||
// replica, epoch, and any workspace lease), as stored in --authority-store.
|
||||
func (env *handoffEnv) lineOf(t *testing.T, v string) string {
|
||||
@@ -234,7 +263,8 @@ func (env *handoffEnv) strandAtGrant(t *testing.T, candidates ...string) string
|
||||
return ""
|
||||
}
|
||||
|
||||
// 1.0.1 red (INV-WS-DELETE-NO-LIVE-HOLDER-001): a line whose epoch HEAD never
|
||||
// INV-WS-DELETE-NO-LIVE-HOLDER-001 (on v1 past the stranded line's lease
|
||||
// horizon: deleteAfterTheHorizon; at once is 1.0.1): a line whose epoch HEAD never
|
||||
// reached has acknowledged nothing, so volume-delete completes WITHOUT a
|
||||
// revoke; HEAD becomes a deleted tombstone, the source is untouched, and no
|
||||
// granted lease stays on the deleted volume. Routes, each without root:
|
||||
@@ -250,12 +280,12 @@ func TestNeverStartedLineIsDeletableWithoutARevoke(t *testing.T) {
|
||||
deleted := func(t *testing.T, env *handoffEnv, v, request string) {
|
||||
t.Helper()
|
||||
before := env.workspaceShow(t, v)
|
||||
out, code := env.deleteNoRevoke(context.Background(), v, request)
|
||||
out, code := env.deleteAfterTheHorizon(t, v, request)
|
||||
completed := code == 0 && handoffDeleteCompleted(out)
|
||||
head, after := env.headOf(t, v), env.workspaceShow(t, v)
|
||||
t.Logf("delete exit %d, completed %v, HEAD %s\nworkspace show before:\n%s\nafter:\n%s\ndelete output:\n%s", code, completed, head, before, after, out)
|
||||
if !completed {
|
||||
t.Fatalf("1.0.1: volume-delete of %s (line above HEAD) must complete without a revoke; exit %d", v, code)
|
||||
t.Fatalf("volume-delete of %s (line above HEAD) must complete without a revoke, past the lease horizon; exit %d", v, code)
|
||||
}
|
||||
if !strings.Contains(head, `"state":"deleted"`) || strings.Contains(after, "lease state: granted") {
|
||||
t.Fatalf("a completed delete must leave a deleted HEAD and no granted lease")
|
||||
@@ -307,7 +337,7 @@ func requireSourceUntouched(t *testing.T, env *handoffEnv) {
|
||||
}
|
||||
}
|
||||
|
||||
// 1.0.1 red: after that delete, a start of the target with the store up
|
||||
// After that delete (on v1 past the lease horizon), a start of the target with the store up
|
||||
// must not claim it: it exits without serving and the HEAD stays deleted.
|
||||
// S1 and S2.
|
||||
func TestNeverStartedLineDeleteFencesALateStart(t *testing.T) {
|
||||
@@ -326,8 +356,8 @@ func TestNeverStartedLineDeleteFencesALateStart(t *testing.T) {
|
||||
} else {
|
||||
v = env.strandAtGrant(t, c.targets...)
|
||||
}
|
||||
if out, code := env.deleteNoRevoke(context.Background(), v, "del-"+v+"-late"); code != 0 {
|
||||
t.Fatalf("1.0.1: volume-delete of %s (line above HEAD): exit %d:\n%s", v, code, out)
|
||||
if out, code := env.deleteAfterTheHorizon(t, v, "del-"+v+"-late"); code != 0 {
|
||||
t.Fatalf("volume-delete of %s (line above HEAD), past the lease horizon: exit %d:\n%s", v, code, out)
|
||||
}
|
||||
b := env.hosts["n-"+v]
|
||||
late := env.h.start(t, "blockvolume-"+v+"-late", env.h.volume, env.volArgsFor(b)...)
|
||||
@@ -380,7 +410,7 @@ func TestNeverStartedLineDeleteRacesAStart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// 1.0.1 red (master restart, one direction): the master is SIGKILLed and
|
||||
// Master restart, one direction (on v1 past the lease horizon): the master is SIGKILLed and
|
||||
// restarted between the stranding and the delete; the delete still completes
|
||||
// without a revoke, from what the master and the HEAD keep durably. S1 and S2.
|
||||
func TestNeverStartedDeleteAfterAMasterRestart(t *testing.T) {
|
||||
@@ -395,9 +425,9 @@ func TestNeverStartedDeleteAfterAMasterRestart(t *testing.T) {
|
||||
env.strandStoreDown(t, v)
|
||||
}
|
||||
restartKilledMaster(t, env)
|
||||
out, code := env.deleteNoRevoke(context.Background(), v, "del-"+v+"-after-restart")
|
||||
out, code := env.deleteAfterTheHorizon(t, v, "del-"+v+"-after-restart")
|
||||
if head := env.headOf(t, v); code != 0 || !strings.Contains(head, `"state":"deleted"`) {
|
||||
t.Fatalf("1.0.1: after a master restart, volume-delete of %s must complete; exit %d, HEAD %s:\n%s", v, code, head, out)
|
||||
t.Fatalf("after a master restart, volume-delete of %s must complete (past the lease horizon); exit %d, HEAD %s:\n%s", v, code, head, out)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -803,7 +803,7 @@ Notes:
|
||||
| `INV-WS-REVOKE-ACK-001` | A host acknowledges a revocation only after its frontend and cuts have stopped; a cancelled or expired drain sends no acknowledgement. | M4 lease guard: Revoking → Acked | `core/host/volume/workspace_lease.go` `drain` | `TestWorkspaceRevocationAckOnlyAfterFrontendAndCutsStop` (`core/host/volume/workspace_lease_test.go`); `TestWorkspaceHostCancelOrExpiryDuringRevokeDrainNeverACKs` (`core/host/volume/workspace_runtime_test.go`) | `WorkspaceTakeover` `CleanNoLoss` | ACTIVE |
|
||||
| `INV-WS-STOP-PENDING-001` | From when the detach hook of a chunk detach runs until the lease guard fences, or until that detach's resume clears stop-pending, each sleep of the guard after a completed renewal is at most 250 ms on the local monotonic clock. | M4 lease guard: Valid → StopPending → Valid \| Fenced | `core/host/volume/workspace_lease.go` `StopPending`, `ClearStopPending`, `renewDelay`, `Run`; `core/host/volume/workspace_runtime.go` `WorkspaceStopPending`, `WorkspaceStopResumed`; `core/frontend/durable/provider_chunk.go` `DetachVolume`, `detachVolume`, `resumeAfterDetach`; `cmd/blockvolume/main.go` `run` (wiring) | `TestWorkspaceLeaseStopPendingSchedule`, `TestWorkspaceHostStopResumedClearsOnlyTheLatestAttempt`, `TestWorkspaceHostFailedDetachStopPendingByOutcome`, `TestWorkspaceHostDetachHookFencesWithinPoll`, `TestWorkspaceLeaseStopPendingNeverBlocks` (`core/host/volume/workspace_lease_stop_pending_test.go`); `TestWALStoreChunk_DetachHookPrecedesDrain`, `TestWALStoreChunk_DetachResumeHookOnlyOnProvenAbort`, `TestWALStoreChunk_DetachCallsStopHook` (`core/frontend/durable/provider_chunk_detach_hook_test.go`) | — | ACTIVE |
|
||||
| `INV-WS-SAME-HOST-CLEAN-MOVE-001` | A same-host move issues a higher epoch: a clean move needs the current holder's sealed HEAD and its recorded epoch/holder/position ACK, and the successor reads that sealed image; a forced move needs the normal lease barrier and a durable lost-range record. | M2 Acked or Expired → Moved; M9 detached → higher-epoch idle | `core/authority/workspace.go` `validateWorkspaceMoveRequest`, `prepareWorkspaceMoveLocked`; `core/host/master/workspace_service.go` `workspaceMoveCheckLocked`; `core/frontend/chunkstore/layout/start.go` `Start`, `core/frontend/chunkstore/layout/claim.go` `Claim` | `TestWorkspaceSameHostForcedMoveRecordsLostRange` (`core/authority/workspace_same_host_forced_test.go`); `TestWorkspaceRPCSameHostForcedRecoveryRecordsLoss` (`core/host/master/workspace_same_host_forced_test.go`); `TestWorkspaceSameHostCleanMoveUsesOvernightSeal` (`core/authority/workspace_same_host_clean_test.go`); `TestWorkspaceRPCSameHostCleanMoveKeepsRepreparedBinding` (`core/host/master/workspace_same_host_clean_test.go`); `TestLayoutSameHostCleanSuccessorReadsSealedImage` (`core/frontend/durable/provider_layout_same_host_clean_test.go`) | `WorkspaceRegrant` `SameHostLoadsSealed`; `INV-SNAPK-DETACHED-001`. The B provider test performs a real plain detach, same-host higher-epoch fresh-root Start, and reads the sealed bytes. | ACTIVE |
|
||||
| `INV-WS-DELETE-NO-LIVE-HOLDER-001` | A workspace volume is marked deleting only with no live holder (`TERM-LIVE-HOLDER-001`): no line, a clean revocation ACK for the line, or HEAD below the line's epoch. A sealed HEAD without an ACK, a live or unreadable one is refused; the HEAD compare-and-swap to deleting fences a later claim. | M2 none/Granted/Revoking/Expired → Deleting | `core/authority/workspace_holder_state.go` `WorkspaceHolderState`; `core/authority/workspace.go` `RecordWorkspaceDeletion`; `core/host/master/services.go` `MarkVolumeDeleting`, `deleteHolderEvidence` | `TestWorkspaceHolderState` (`core/authority/workspace_holder_state_test.go`); `TestDeleteAdmitsANeverStartedLine` (`core/host/master/workspace_delete_never_started_test.go`); `TestDeleteAdmissionVerdicts` (`core/authority/workspace_delete_admission_test.go`); `TestMarkVolumeDeleting_RefusedWhileAssigned` (`core/host/master/volume_deleting_test.go`) | NeverStarted r2 `DeleteNeverStrandsALiveHolder`, `NoServedWriteLost`, re-run can finish, re-run can settle (exhaustive, 21 of 21 configurations as expected). Not modelled: two delete processes at the same instant; the gap between HEAD deleted and the volume marked deleted | ACTIVE |
|
||||
| `INV-WS-DELETE-NO-LIVE-HOLDER-001` | A workspace volume is marked deleting only with no live holder (`TERM-LIVE-HOLDER-001`): no line, a clean revocation ACK for the line, or HEAD below the line's epoch. A sealed HEAD without an ACK, a live or unreadable one is refused; the HEAD compare-and-swap to deleting fences a later claim. | M2 none/Granted/Revoking/Expired → Deleting | `core/authority/workspace_holder_state.go` `WorkspaceHolderState`; `core/authority/workspace.go` `RecordWorkspaceDeletion`; `core/host/master/services.go` `MarkVolumeDeleting`, `deleteHolderEvidence` | `TestWorkspaceHolderState` (`core/authority/workspace_holder_state_test.go`); `TestDeleteAdmitsANeverStartedLine` (`core/host/master/workspace_delete_never_started_test.go`); `TestDeleteAdmissionVerdicts` (`core/authority/workspace_delete_admission_test.go`); `TestMarkVolumeDeleting_RefusedWhileAssigned` (`core/host/master/volume_deleting_test.go`) | NeverStarted r2 `DeleteNeverStrandsALiveHolder`, `NoServedWriteLost`, re-run can finish, re-run can settle (exhaustive, 21 of 21 configurations as expected). Not modelled: two delete processes at the same instant; the gap between HEAD deleted and the volume marked deleted. Limit (v1): a never-started line that holds a lease is deleted once its lease horizon passed (about 60 s; the reservation refuses a live lease before it); the immediate exit is 1.0.1 | ACTIVE |
|
||||
| `INV-WS-CLEAN-MOVE-001` | A clean move is granted only with a detached HEAD from the expected holder and a revocation ACK matching its epoch, holder and published position; generation is readout only. | M2 lease: Acked → Moved | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `AckWorkspaceRevocation`; `core/host/master/workspace_layout_head.go` `NewLayoutWorkspaceHEADReader` | `TestWorkspaceCleanMoveNeedsDetachedHEADAndRevocationAck` (`core/authority/workspace_test.go`); `TestWorkspaceLayoutHEADUsesTheMasterIdentity`, `TestWorkspaceLayoutHEADRefusalsAndStates`, `TestWorkspaceLayoutHEADReaderWiring` | `WorkspaceTakeover` `CleanNoLoss` | ACTIVE |
|
||||
| `INV-WS-FORCED-MOVE-001` | A forced move is admitted only after the persisted lease horizon and the granted or restart deadline, each plus the clock-skew bound, have passed for the lease the last move issue started (never a predecessor's): see M2 Expired → Moved (forced). | M2 lease: Expired → Moved (forced) | `core/authority/workspace.go` `prepareWorkspaceMoveLocked`, `WorkspaceForcedMoveAdmitted`, `forcedMoveAdmissionLocked`, `forcedMoveBarrierLocked`, `workspaceHeadAdmits`; `core/host/master/workspace_service.go` `MoveWorkspace`, `workspaceMoveCheckLocked` | `TestWorkspaceSkewSeparatesOldServingFromForcedGrant` (`core/host/master/workspace_skew_test.go`); `TestWorkspaceClockSkewPersistsAndProtectsRestart` (`core/authority/workspace_skew_test.go`); `TestWorkspaceForcedMoveRequiresExplicitForceAndLeaseExpiry` (`core/authority/workspace_test.go`); `TestWorkspaceRestartForcedBarrierHonoursHorizon`, `TestWorkspaceAmbiguousExtensionLatchesUncertainty` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceRenewalRPCDuringHeldSameVolumeReservation` (`core/host/master/workspace_lease_horizon_test.go`); `TestWorkspaceUnclaimedGrantForcedReassignAfterExpiry`, `TestWorkspaceUnclaimedGrantHEADRule`, `TestWorkspaceLateClaimThenUnclaimedGrantForcedReassign` (`core/authority/workspace_unclaimed_grant_test.go`); `TestWorkspaceForcedMoveAdmittedMatchesMoveAdmission` (`core/authority/workspace_forced_admission_test.go`); `TestWorkspaceUnclaimedGrantForcedReassignOverRPC` (`core/host/master/workspace_unclaimed_grant_test.go`); `TestWorkspacePausedGranteeRefusedAtAttach` (`core/host/master/workspace_paused_grantee_test.go`); `TestProcedureMasterUnreachableFencesBeforeForcedMove` (`cmd/blockvolume/master_loss_integration_test.go`, tags `subprocess chunkstore_integration`) | — | ACTIVE |
|
||||
| `INV-WS-FORCED-MOVE-REPLY-001` | The lease expiry the master reports to a host is the granted expiry, never the persisted horizon. | M2 Granted → Granted; Granted → Revoking | `core/authority/workspace_lease_view.go` `RenewWorkspaceLease`, `WorkspaceLeaseReply`, `replyExpiryNS`; `core/host/master/workspace_service.go` `RevokeWorkspace` | `TestWorkspaceLeaseClampsToHorizonUnderStalledStore`, `TestWorkspaceSameVolumeRenewalDuringHeldWrite` (`core/authority/workspace_lease_horizon_test.go`); `TestWorkspaceUnclaimedGrantForcedReassignAfterExpiry` (`core/authority/workspace_unclaimed_grant_test.go`) | — | ACTIVE |
|
||||
|
||||
Reference in new issue
Block a user