mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
fix: preserve absent operation queries while fencing index creation
This commit is contained in:
1 parent
40952ad00d
commit
39dcc4aed1
3 files changed
+14
-12
No files matched your search
@@ -24,6 +24,7 @@ import (
|
||||
// pins it. "GAP" marks a reader that takes an absent HEAD for an empty
|
||||
// one; a change that treats an absent HEAD as unknown flips those probes.
|
||||
var headReaders = map[string]string{
|
||||
"core/frontend/chunkstore/snapshot_operation_index.go writeOperationIndex -> ReadHead": "absent HEAD refuses first-index publication; deleting/deleted refuses sequence reset after namespace cleanup (TestSnapshotOperationCleanupRequiresDeletedHead, TestSnapshotOperationVolumeDeleteEndsNamespace)",
|
||||
"core/frontend/chunkstore/layout/delete_intent.go adoptDeleteIntentPage -> ReadHead": "absence refuses adoption (probe TestDeleteIntentAdoptionCannotRestoreStaleTags)",
|
||||
"core/frontend/chunkstore/layout/delete_intent.go StageSnapshotDeletePage -> ReadHead": "refuses ErrHeadAbsent before staging (probe TestLayoutDeleteIntentAbsentHEAD)",
|
||||
"core/frontend/chunkstore/layout/delete_intent.go RunDeleteSnapshotWithIntent -> ReadHead": "absence cannot settle unknown unlink (probe TestLayoutDeleteIntentAbsentHEAD and TestRunDeleteSnapshotWithIntent_InterruptAtEveryStep)",
|
||||
@@ -71,7 +72,6 @@ var headReaders = map[string]string{
|
||||
"core/frontend/chunkstore/layout/create.go createVolume -> ReadHead": "reads HEAD only after its exclusive create found one; absent then refuses ErrIdentity, writes nothing more (probe LayoutCreate)",
|
||||
"core/frontend/chunkstore/layout/head.go runTransition -> ReadHead": "refuses ErrHeadAbsent and writes nothing; no layout transition creates a HEAD (probe LayoutTransition)",
|
||||
"core/frontend/chunkstore/snapshot_operation_cleanup.go deleteSnapshotOperations -> ReadHead": "absent or not-deleted HEAD refuses cleanup without deleting operation authority (TestSnapshotOperationCleanupRequiresDeletedHead)",
|
||||
"core/frontend/chunkstore/snapshot_operation_index.go readOperationIndex -> ReadHead": "absent HEAD refuses empty-index admission; deleting/deleted refuses sequence reset after namespace cleanup (TestSnapshotOperationCleanupRequiresDeletedHead, TestSnapshotOperationVolumeDeleteEndsNamespace)",
|
||||
// above the chunk store: they read through the layout remote's GetHead, so an
|
||||
// absent HEAD reaches them as ErrHeadAbsent, never as a zero HEAD (probe LayoutRemote)
|
||||
"cmd/sw-block/chunk_b.go chunkShowContext -> ReadHead": "found=false: prints a null head, including via the chunkShow wrapper (probe TestOpsChunk_AbsentVolume)",
|
||||
|
||||
@@ -87,16 +87,6 @@ func (s *LayoutStore) readOperationIndex(ctx context.Context) (operationIndex, e
|
||||
return operationIndex{}, remoteErr(listErr, "snapshot operation index evidence")
|
||||
}
|
||||
if len(files) == 0 {
|
||||
h, found, headErr := s.ReadHead(ctx)
|
||||
if headErr != nil {
|
||||
return operationIndex{}, headErr
|
||||
}
|
||||
if !found {
|
||||
return operationIndex{}, layout.ErrHeadAbsent
|
||||
}
|
||||
if h.State == layout.StateDeleting || h.State == layout.StateDeleted {
|
||||
return operationIndex{}, layout.ErrVolumeDeleting
|
||||
}
|
||||
return operationIndex{next: 1}, nil
|
||||
}
|
||||
// Another executor may have created the index and its receipt after
|
||||
@@ -142,6 +132,18 @@ func (s *LayoutStore) readOperationIndex(ctx context.Context) (operationIndex, e
|
||||
// false means a concurrent index CAS won. Operational uncertainty is never
|
||||
// treated as a failed publication: the caller retries its same operation ID.
|
||||
func (s *LayoutStore) writeOperationIndex(ctx context.Context, previous uint64, idx operationIndex) (bool, error) {
|
||||
if previous == 0 {
|
||||
h, found, err := s.ReadHead(ctx)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if !found {
|
||||
return false, layout.ErrHeadAbsent
|
||||
}
|
||||
if h.State == layout.StateDeleting || h.State == layout.StateDeleted {
|
||||
return false, layout.ErrVolumeDeleting
|
||||
}
|
||||
}
|
||||
if previous == ^uint64(0) {
|
||||
return false, errors.New("chunkstore: operation index revision exhausted")
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func TestSnapshotOperationVolumeDeleteEndsNamespace(t *testing.T) {
|
||||
if err != nil || len(entries) != 0 {
|
||||
t.Fatalf("operation namespace survived volume deletion: entries=%v err=%v", entries, err)
|
||||
}
|
||||
if _, err := s.ReadSnapshotOperationHandle(ctx, op.ID, op.Verb, op.Instance, op.Sequence); !errors.Is(err, layout.ErrVolumeDeleting) && !errors.Is(err, ErrSnapshotOperationRetired) {
|
||||
if _, err := s.ReadSnapshotOperationHandle(ctx, op.ID, op.Verb, op.Instance, op.Sequence); !errors.Is(err, ErrSnapshotOperationIntent) {
|
||||
t.Fatalf("deleted volume answered old operation: %v", err)
|
||||
}
|
||||
if _, _, err := s.CreateSnapshotOperation(ctx, "new", "create", "new", strings.Repeat("b", 64)); !errors.Is(err, layout.ErrVolumeDeleting) {
|
||||
|
||||
Reference in new issue
Block a user