From cccad8d5ceb97bf23cd560b50bbacc32b4447527 Mon Sep 17 00:00:00 2001 From: Ping Qiu Date: Sat, 5 Dec 2026 11:29:24 -0800 Subject: [PATCH] seaweed-block: a stale metadata change cannot land on a re-created intent page (filer chunk condition, page re-read as fallback) (#13457) * seaweed-block: red: a snapshot delete is published over a page whose data was freed Two overlapping runs of one snapshot delete write their intent pages under the same tag. If the first run's stalled page update lands between the second run's read of a page and its adoption (after a cleaning pass deleted and the second run re-staged the page), the second run adopts and publishes an intent whose page data was freed: later snapshot deletes on the volume are refused and its cleaning stops. Co-Authored-By: Claude Opus 5.5 * seaweed-block: a snapshot delete re-reads each intent page after adopting it Publication reads every intent page, adopts it under this run's tag, then publishes. A stalled update from another run of the same delete can land between that read and the adoption and put a deleted page's data reference on the entry. Reading the page again after the adoption, before the transition publishes, refuses that case: once this run's tag is on the entry, no such update passes. No persisted change; a run that hits it stays refused, and a new request id writes new pages. Co-Authored-By: Claude Opus 5.5 * seaweed-block: ledger row for the intent page re-read INV-SNAPSHOT-DELETE-ADOPT-002 names the re-read after adoption, its test and the model row it projects (PublishedReadable; the refused run is the residue a new request id clears). Co-Authored-By: Claude Opus 5.5 * seaweed-block: the intent page re-read: typed refusal, twins and a store witness Review: the re-read test now separates the guard from weaker ones. A page that reads but holds other bytes, and a change to only the later of two pages, are refused as well as a freed page; the refusal is a precondition that writes nothing to HEAD, keeps the snapshot, and comes after the adoption; the same schedule with intact bytes publishes. The test is a consequence-level projection; a store-level witness shows the tag-only metadata update writing a deleted object's chunk over a re-created one, which the re-read does not depend on refusing. The ledger row names the witness and marks the model as checked outside the repository. Co-Authored-By: Claude Opus 5.5 * seaweed-block: the intent page re-read keeps its error's cause The refusal wrapped the re-read's error with %v, so a caller deadline that ended the re-read reached the CLI as a precondition ("page changed during adoption", no_progress) instead of deadline_exceeded, unlike the same deadline on the chain's first read. Wrap both errors. Co-Authored-By: Claude Opus 5.5 * seaweed-block: the intent page re-read sees only data the filer already freed The filer frees a deleted entry's chunks, and the chunks an update drops, from its deletion queue: polled every 1.123 s, and retried after 5 min when a volume server does not answer. A stale update that puts such a reference on an adopted page therefore reads back intact while the deletion is still queued, and the intent publishes over data that is freed moments later. The intact-bytes twin publishes for that reason. State that bound in INV-SNAPSHOT-DELETE-ADOPT-002 and at the guard instead of "changed or vanished ... refuses the publication". Co-Authored-By: Claude Opus 5.5 * seaweed-block: the delete intent publication row and diagram carry the re-read Part C rule 2 moves a changed guard's Part A row and diagram with it. The publication row now names the re-read after adoption and INV-SNAPSHOT-DELETE-ADOPT-002, and the M9 diagram gains the transition's idle and snap self-loops, which it lacked. Co-Authored-By: Claude Opus 5.5 * seaweed-block: red: a stale adoption or mark lands on a re-created object A metadata change writes the looked-up entry back, chunks included, conditional only on its tags: paused between its lookup and its update, it lands on an object deleted and created again with the same tags in between, puts the deleted object's chunk on it, and a cleaner's stale mark then deletes it. The filer's IF_CHUNKS_EQUAL condition refuses such a write. This commit adds the plumbing and the tests, not the guard itself: - the filer protocol subset gains WriteCondition (IF_CHUNKS_EQUAL) on UpdateEntryRequest; SWFS sends it through UpdateEntryIfChunks, and the fakes evaluate it (or drop it, as an older filer does); - a startup probe sends a mismatched conditional update to the disposable probe HEAD; only a definite refusal turns the guard on for the stores the catalog opens. The startup log and /status/chunk (metadata_guard) name it. The two guard tests fail here: changeMeta does not send the condition yet. Co-Authored-By: Claude Opus 5.5 * seaweed-block: metadata changes send the filer's chunk condition With the guard on (the startup probe saw the filer enforce it), an adoption or mark sends IF_CHUNKS_EQUAL with the looked-up entry's chunk fids. A re-created object always has a new chunk, so a stale whole-entry write is refused instead of putting a deleted object's chunk on it; a cleaner's delete expects its own mark and so follows. Without the guard the write is unchanged and the intent page re-read stays the check. Co-Authored-By: Claude Opus 5.5 * seaweed-block: ledger rows for the chunk condition and its probe INV-LAYOUT-META-CHUNKS-001 (adoption and mark under IF_CHUNKS_EQUAL) and INV-WS-CHUNK-CONDITION-PROBE-001 (the startup probe decides it, the log and /status/chunk name it); ADOPT-002 names the renamed store test. Co-Authored-By: Claude Opus 5.5 * seaweed-block: the chunk probe without a definite refusal leaves the guard off; fallback wording Review: the existing failure cases stop at the HEAD gate. New cases pass the gate and then fail only the chunk condition probe (unavailable, lost, deadline, filer error, vanished entry, failed HEAD read): the catalog, its stores, the startup log and the usage all stay on page_reread_only. page_reread_only now reads as enforcement not established, not as a filer without the condition; INV-SNAPSHOT-DELETE-ADOPT-002 cites MetaABA r2's delayed-free counterexample, r1 kept as historical scope. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 Co-authored-by: Chris Lu --- .../core/frontend/chunkstore/catalog_b.go | 30 +- .../core/frontend/chunkstore/fake_test.go | 19 + .../chunkstore/filerpb/filer_subset.pb.go | 375 +++++++++++++----- .../chunkstore/filerpb/filer_subset.proto | 17 + .../frontend/chunkstore/head_readers_test.go | 1 + .../chunkstore/layout/delete_intent.go | 12 + .../layout/delete_intent_reread_test.go | 171 ++++++++ .../layout_change_meta_recreated_test.go | 218 ++++++++++ .../core/frontend/chunkstore/layout_store.go | 22 + .../core/frontend/chunkstore/memfiler.go | 17 + .../core/frontend/chunkstore/remote.go | 43 ++ .../startup_chunk_condition_probe_test.go | 80 ++++ .../frontend/chunkstore/startup_head_probe.go | 29 ++ .../chunkstore/startup_head_probe_test.go | 91 ++++- .../core/frontend/chunkstore/swfs.go | 13 +- .../core/host/volume/status_chunk_test.go | 2 +- seaweed-block/docs/design/invariants.md | 7 +- seaweed-block/docs/status-schema.md | 1 + 18 files changed, 1035 insertions(+), 113 deletions(-) create mode 100644 seaweed-block/core/frontend/chunkstore/layout/delete_intent_reread_test.go create mode 100644 seaweed-block/core/frontend/chunkstore/layout_change_meta_recreated_test.go create mode 100644 seaweed-block/core/frontend/chunkstore/startup_chunk_condition_probe_test.go diff --git a/seaweed-block/core/frontend/chunkstore/catalog_b.go b/seaweed-block/core/frontend/chunkstore/catalog_b.go index ac2a1f73de..37a6c472ed 100644 --- a/seaweed-block/core/frontend/chunkstore/catalog_b.go +++ b/seaweed-block/core/frontend/chunkstore/catalog_b.go @@ -31,6 +31,9 @@ type BCatalog struct { base string cleanMu sync.Mutex cursors map[VolumeRef]*cleanCursor + // chunkGuard: the startup probe saw the filer refuse a mismatched + // IF_CHUNKS_EQUAL update; every store it opens sends the condition. + chunkGuard bool } // NewBCatalog returns the catalog of the volumes under base. @@ -49,9 +52,29 @@ func (c *BCatalog) Store(v VolumeRef) (*LayoutStore, error) { } counts, _ := c.headWrites.LoadOrStore(v.Dir(), s.headWrites) s.headWrites = counts.(*headWriteCounters) + s.chunkGuard = c.chunkGuard return s, nil } +// Metadata change protections, as /status and the startup log name them. +const ( + MetadataGuardChunks = "filer_chunk_condition" // the probe saw IF_CHUNKS_EQUAL enforced; the page re-read stays as well + // MetadataGuardReread: enforcement was not established. The filer + // applied the probe, or did not answer it definitely, or this client + // cannot send the condition; it says nothing about what the filer + // supports. The re-read is the only check. + MetadataGuardReread = "page_reread_only" +) + +// MetadataGuard names the protection this catalog's metadata changes run +// under, decided once by the startup probe. +func (c *BCatalog) MetadataGuard() string { + if c.chunkGuard { + return MetadataGuardChunks + } + return MetadataGuardReread +} + func (c *BCatalog) open(v VolumeRef) (*LayoutStore, *layout.Reader, error) { s, err := c.Store(v) if err != nil { @@ -343,6 +366,11 @@ type Usage struct { Dependents int `json:"dependents"` OwnChunks int `json:"own_chunks"` ForeignChunks int `json:"foreign_chunks"` + // MetadataGuard names the protection of the volume's metadata changes: + // filer_chunk_condition (the startup probe saw the filer enforce the + // chunk condition) or page_reread_only (enforcement was not established + // at startup; delete intent pages are re-read). + MetadataGuard string `json:"metadata_guard"` } // Usage reads the volume's usage from its HEAD and current root. @@ -358,7 +386,7 @@ func (c *BCatalog) Usage(ctx context.Context, v VolumeRef) (Usage, error) { if !found { return Usage{}, layout.ErrHeadAbsent } - u := Usage{Snapshots: len(h.Snapshots)} + u := Usage{Snapshots: len(h.Snapshots), MetadataGuard: c.MetadataGuard()} for _, sn := range h.Snapshots { u.Dependents += len(sn.Dependents) } diff --git a/seaweed-block/core/frontend/chunkstore/fake_test.go b/seaweed-block/core/frontend/chunkstore/fake_test.go index b1bc06d73f..28bb19510f 100644 --- a/seaweed-block/core/frontend/chunkstore/fake_test.go +++ b/seaweed-block/core/frontend/chunkstore/fake_test.go @@ -64,6 +64,9 @@ type fakeFiler struct { // (lookups overlap) and bounded by ctx, as a remote filer's. slowLookup func(p string) time.Duration deferredCreates []deferredCreate + // ignoreChunkCondition makes UpdateEntryIfChunks ignore its condition, + // as a filer that predates IF_CHUNKS_EQUAL drops the unknown field. + ignoreChunkCondition bool } func newFakeFiler() *fakeFiler { return &fakeFiler{entries: map[string]*filerpb.Entry{}} } @@ -137,6 +140,19 @@ func (f *fakeFiler) CreateEntry(ctx context.Context, dir string, e *filerpb.Entr } func (f *fakeFiler) UpdateEntry(_ context.Context, dir string, e *filerpb.Entry, expected map[string][]byte) error { + return f.updateEntry(dir, e, expected, nil) +} + +// UpdateEntryIfChunks evaluates IF_CHUNKS_EQUAL as the filer does (stored +// chunk fids equal fids as a multiset), unless ignoreChunkCondition. +func (f *fakeFiler) UpdateEntryIfChunks(_ context.Context, dir string, e *filerpb.Entry, expected map[string][]byte, fids []string) error { + if fids == nil { + fids = []string{} + } + return f.updateEntry(dir, e, expected, fids) +} + +func (f *fakeFiler) updateEntry(dir string, e *filerpb.Entry, expected map[string][]byte, fids []string) error { f.mu.Lock() defer f.mu.Unlock() p := path.Join(dir, e.Name) @@ -155,6 +171,9 @@ func (f *fakeFiler) UpdateEntry(_ context.Context, dir string, e *filerpb.Entry, return fmt.Errorf("%w: extended %q changed", ErrPrecondition, k) } } + if fids != nil && !f.ignoreChunkCondition && !fidsEqual(entryFids(cur), fids) { + return fmt.Errorf("%w: chunks of %s changed", ErrPrecondition, p) + } f.entries[p] = proto.Clone(e).(*filerpb.Entry) f.written = append(f.written, proto.Clone(e).(*filerpb.Entry)) f.updates++ diff --git a/seaweed-block/core/frontend/chunkstore/filerpb/filer_subset.pb.go b/seaweed-block/core/frontend/chunkstore/filerpb/filer_subset.pb.go index d97b8f6085..decb9a253a 100644 --- a/seaweed-block/core/frontend/chunkstore/filerpb/filer_subset.pb.go +++ b/seaweed-block/core/frontend/chunkstore/filerpb/filer_subset.pb.go @@ -97,6 +97,52 @@ func (FilerError) EnumDescriptor() ([]byte, []int) { return file_filer_subset_proto_rawDescGZIP(), []int{0} } +type WriteCondition_Kind int32 + +const ( + WriteCondition_NONE WriteCondition_Kind = 0 + WriteCondition_IF_CHUNKS_EQUAL WriteCondition_Kind = 9 // fail unless the stored chunk fid multiset equals fids (absent entry = no chunks) +) + +// Enum value maps for WriteCondition_Kind. +var ( + WriteCondition_Kind_name = map[int32]string{ + 0: "NONE", + 9: "IF_CHUNKS_EQUAL", + } + WriteCondition_Kind_value = map[string]int32{ + "NONE": 0, + "IF_CHUNKS_EQUAL": 9, + } +) + +func (x WriteCondition_Kind) Enum() *WriteCondition_Kind { + p := new(WriteCondition_Kind) + *p = x + return p +} + +func (x WriteCondition_Kind) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (WriteCondition_Kind) Descriptor() protoreflect.EnumDescriptor { + return file_filer_subset_proto_enumTypes[1].Descriptor() +} + +func (WriteCondition_Kind) Type() protoreflect.EnumType { + return &file_filer_subset_proto_enumTypes[1] +} + +func (x WriteCondition_Kind) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use WriteCondition_Kind.Descriptor instead. +func (WriteCondition_Kind) EnumDescriptor() ([]byte, []int) { + return file_filer_subset_proto_rawDescGZIP(), []int{9, 0} +} + type LookupDirectoryEntryRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Directory string `protobuf:"bytes,1,opt,name=directory,proto3" json:"directory,omitempty"` @@ -711,6 +757,54 @@ func (x *CreateEntryResponse) GetErrorCode() FilerError { return FilerError_OK } +// WriteCondition is copied from weed/pb/filer.proto (this repository): the +// IF_CHUNKS_EQUAL clause only. A filer that predates it drops field 6 of +// UpdateEntryRequest as unknown and applies the write unguarded, so the +// chunkstore decides at startup, by a probe, whether it is enforced. +type WriteCondition struct { + state protoimpl.MessageState `protogen:"open.v1"` + Clauses []*WriteCondition_Clause `protobuf:"bytes,1,rep,name=clauses,proto3" json:"clauses,omitempty"` // all must hold (logical AND) + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WriteCondition) Reset() { + *x = WriteCondition{} + mi := &file_filer_subset_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WriteCondition) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteCondition) ProtoMessage() {} + +func (x *WriteCondition) ProtoReflect() protoreflect.Message { + mi := &file_filer_subset_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WriteCondition.ProtoReflect.Descriptor instead. +func (*WriteCondition) Descriptor() ([]byte, []int) { + return file_filer_subset_proto_rawDescGZIP(), []int{9} +} + +func (x *WriteCondition) GetClauses() []*WriteCondition_Clause { + if x != nil { + return x.Clauses + } + return nil +} + type UpdateEntryRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Directory string `protobuf:"bytes,1,opt,name=directory,proto3" json:"directory,omitempty"` @@ -718,13 +812,14 @@ type UpdateEntryRequest struct { IsFromOtherCluster bool `protobuf:"varint,3,opt,name=is_from_other_cluster,json=isFromOtherCluster,proto3" json:"is_from_other_cluster,omitempty"` Signatures []int32 `protobuf:"varint,4,rep,packed,name=signatures,proto3" json:"signatures,omitempty"` ExpectedExtended map[string][]byte `protobuf:"bytes,5,rep,name=expected_extended,json=expectedExtended,proto3" json:"expected_extended,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + Condition *WriteCondition `protobuf:"bytes,6,opt,name=condition,proto3" json:"condition,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *UpdateEntryRequest) Reset() { *x = UpdateEntryRequest{} - mi := &file_filer_subset_proto_msgTypes[9] + mi := &file_filer_subset_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -736,7 +831,7 @@ func (x *UpdateEntryRequest) String() string { func (*UpdateEntryRequest) ProtoMessage() {} func (x *UpdateEntryRequest) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[9] + mi := &file_filer_subset_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -749,7 +844,7 @@ func (x *UpdateEntryRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateEntryRequest.ProtoReflect.Descriptor instead. func (*UpdateEntryRequest) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{9} + return file_filer_subset_proto_rawDescGZIP(), []int{10} } func (x *UpdateEntryRequest) GetDirectory() string { @@ -787,6 +882,13 @@ func (x *UpdateEntryRequest) GetExpectedExtended() map[string][]byte { return nil } +func (x *UpdateEntryRequest) GetCondition() *WriteCondition { + if x != nil { + return x.Condition + } + return nil +} + type UpdateEntryResponse struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -795,7 +897,7 @@ type UpdateEntryResponse struct { func (x *UpdateEntryResponse) Reset() { *x = UpdateEntryResponse{} - mi := &file_filer_subset_proto_msgTypes[10] + mi := &file_filer_subset_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -807,7 +909,7 @@ func (x *UpdateEntryResponse) String() string { func (*UpdateEntryResponse) ProtoMessage() {} func (x *UpdateEntryResponse) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[10] + mi := &file_filer_subset_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -820,7 +922,7 @@ func (x *UpdateEntryResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use UpdateEntryResponse.ProtoReflect.Descriptor instead. func (*UpdateEntryResponse) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{10} + return file_filer_subset_proto_rawDescGZIP(), []int{11} } type DeleteEntryRequest struct { @@ -836,7 +938,7 @@ type DeleteEntryRequest struct { func (x *DeleteEntryRequest) Reset() { *x = DeleteEntryRequest{} - mi := &file_filer_subset_proto_msgTypes[11] + mi := &file_filer_subset_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -848,7 +950,7 @@ func (x *DeleteEntryRequest) String() string { func (*DeleteEntryRequest) ProtoMessage() {} func (x *DeleteEntryRequest) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[11] + mi := &file_filer_subset_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -861,7 +963,7 @@ func (x *DeleteEntryRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteEntryRequest.ProtoReflect.Descriptor instead. func (*DeleteEntryRequest) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{11} + return file_filer_subset_proto_rawDescGZIP(), []int{12} } func (x *DeleteEntryRequest) GetDirectory() string { @@ -908,7 +1010,7 @@ type DeleteEntryResponse struct { func (x *DeleteEntryResponse) Reset() { *x = DeleteEntryResponse{} - mi := &file_filer_subset_proto_msgTypes[12] + mi := &file_filer_subset_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -920,7 +1022,7 @@ func (x *DeleteEntryResponse) String() string { func (*DeleteEntryResponse) ProtoMessage() {} func (x *DeleteEntryResponse) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[12] + mi := &file_filer_subset_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -933,7 +1035,7 @@ func (x *DeleteEntryResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DeleteEntryResponse.ProtoReflect.Descriptor instead. func (*DeleteEntryResponse) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{12} + return file_filer_subset_proto_rawDescGZIP(), []int{13} } func (x *DeleteEntryResponse) GetError() string { @@ -961,7 +1063,7 @@ type AssignVolumeRequest struct { func (x *AssignVolumeRequest) Reset() { *x = AssignVolumeRequest{} - mi := &file_filer_subset_proto_msgTypes[13] + mi := &file_filer_subset_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -973,7 +1075,7 @@ func (x *AssignVolumeRequest) String() string { func (*AssignVolumeRequest) ProtoMessage() {} func (x *AssignVolumeRequest) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[13] + mi := &file_filer_subset_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -986,7 +1088,7 @@ func (x *AssignVolumeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AssignVolumeRequest.ProtoReflect.Descriptor instead. func (*AssignVolumeRequest) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{13} + return file_filer_subset_proto_rawDescGZIP(), []int{14} } func (x *AssignVolumeRequest) GetCount() int32 { @@ -1077,7 +1179,7 @@ type AssignVolumeResponse struct { func (x *AssignVolumeResponse) Reset() { *x = AssignVolumeResponse{} - mi := &file_filer_subset_proto_msgTypes[14] + mi := &file_filer_subset_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1089,7 +1191,7 @@ func (x *AssignVolumeResponse) String() string { func (*AssignVolumeResponse) ProtoMessage() {} func (x *AssignVolumeResponse) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[14] + mi := &file_filer_subset_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1102,7 +1204,7 @@ func (x *AssignVolumeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AssignVolumeResponse.ProtoReflect.Descriptor instead. func (*AssignVolumeResponse) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{14} + return file_filer_subset_proto_rawDescGZIP(), []int{15} } func (x *AssignVolumeResponse) GetFileId() string { @@ -1184,7 +1286,7 @@ type LookupVolumeRequest struct { func (x *LookupVolumeRequest) Reset() { *x = LookupVolumeRequest{} - mi := &file_filer_subset_proto_msgTypes[15] + mi := &file_filer_subset_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1196,7 +1298,7 @@ func (x *LookupVolumeRequest) String() string { func (*LookupVolumeRequest) ProtoMessage() {} func (x *LookupVolumeRequest) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[15] + mi := &file_filer_subset_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1209,7 +1311,7 @@ func (x *LookupVolumeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use LookupVolumeRequest.ProtoReflect.Descriptor instead. func (*LookupVolumeRequest) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{15} + return file_filer_subset_proto_rawDescGZIP(), []int{16} } func (x *LookupVolumeRequest) GetVolumeIds() []string { @@ -1228,7 +1330,7 @@ type Locations struct { func (x *Locations) Reset() { *x = Locations{} - mi := &file_filer_subset_proto_msgTypes[16] + mi := &file_filer_subset_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1240,7 +1342,7 @@ func (x *Locations) String() string { func (*Locations) ProtoMessage() {} func (x *Locations) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[16] + mi := &file_filer_subset_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1253,7 +1355,7 @@ func (x *Locations) ProtoReflect() protoreflect.Message { // Deprecated: Use Locations.ProtoReflect.Descriptor instead. func (*Locations) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{16} + return file_filer_subset_proto_rawDescGZIP(), []int{17} } func (x *Locations) GetLocations() []*Location { @@ -1276,7 +1378,7 @@ type Location struct { func (x *Location) Reset() { *x = Location{} - mi := &file_filer_subset_proto_msgTypes[17] + mi := &file_filer_subset_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1288,7 +1390,7 @@ func (x *Location) String() string { func (*Location) ProtoMessage() {} func (x *Location) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[17] + mi := &file_filer_subset_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1301,7 +1403,7 @@ func (x *Location) ProtoReflect() protoreflect.Message { // Deprecated: Use Location.ProtoReflect.Descriptor instead. func (*Location) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{17} + return file_filer_subset_proto_rawDescGZIP(), []int{18} } func (x *Location) GetUrl() string { @@ -1348,7 +1450,7 @@ type LookupVolumeResponse struct { func (x *LookupVolumeResponse) Reset() { *x = LookupVolumeResponse{} - mi := &file_filer_subset_proto_msgTypes[18] + mi := &file_filer_subset_proto_msgTypes[19] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1360,7 +1462,7 @@ func (x *LookupVolumeResponse) String() string { func (*LookupVolumeResponse) ProtoMessage() {} func (x *LookupVolumeResponse) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[18] + mi := &file_filer_subset_proto_msgTypes[19] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1373,7 +1475,7 @@ func (x *LookupVolumeResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use LookupVolumeResponse.ProtoReflect.Descriptor instead. func (*LookupVolumeResponse) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{18} + return file_filer_subset_proto_rawDescGZIP(), []int{19} } func (x *LookupVolumeResponse) GetLocationsMap() map[string]*Locations { @@ -1391,7 +1493,7 @@ type GetFilerConfigurationRequest struct { func (x *GetFilerConfigurationRequest) Reset() { *x = GetFilerConfigurationRequest{} - mi := &file_filer_subset_proto_msgTypes[19] + mi := &file_filer_subset_proto_msgTypes[20] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1403,7 +1505,7 @@ func (x *GetFilerConfigurationRequest) String() string { func (*GetFilerConfigurationRequest) ProtoMessage() {} func (x *GetFilerConfigurationRequest) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[19] + mi := &file_filer_subset_proto_msgTypes[20] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1416,7 +1518,7 @@ func (x *GetFilerConfigurationRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetFilerConfigurationRequest.ProtoReflect.Descriptor instead. func (*GetFilerConfigurationRequest) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{19} + return file_filer_subset_proto_rawDescGZIP(), []int{20} } // Only the fields the single-filer startup check reads. @@ -1430,7 +1532,7 @@ type GetFilerConfigurationResponse struct { func (x *GetFilerConfigurationResponse) Reset() { *x = GetFilerConfigurationResponse{} - mi := &file_filer_subset_proto_msgTypes[20] + mi := &file_filer_subset_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1442,7 +1544,7 @@ func (x *GetFilerConfigurationResponse) String() string { func (*GetFilerConfigurationResponse) ProtoMessage() {} func (x *GetFilerConfigurationResponse) ProtoReflect() protoreflect.Message { - mi := &file_filer_subset_proto_msgTypes[20] + mi := &file_filer_subset_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1455,7 +1557,7 @@ func (x *GetFilerConfigurationResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetFilerConfigurationResponse.ProtoReflect.Descriptor instead. func (*GetFilerConfigurationResponse) Descriptor() ([]byte, []int) { - return file_filer_subset_proto_rawDescGZIP(), []int{20} + return file_filer_subset_proto_rawDescGZIP(), []int{21} } func (x *GetFilerConfigurationResponse) GetMasters() []string { @@ -1472,6 +1574,58 @@ func (x *GetFilerConfigurationResponse) GetFilerGroup() string { return "" } +type WriteCondition_Clause struct { + state protoimpl.MessageState `protogen:"open.v1"` + Kind WriteCondition_Kind `protobuf:"varint,1,opt,name=kind,proto3,enum=filer_pb.WriteCondition_Kind" json:"kind,omitempty"` + Fids []string `protobuf:"bytes,9,rep,name=fids,proto3" json:"fids,omitempty"` // chunk fid strings for IF_CHUNKS_EQUAL + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *WriteCondition_Clause) Reset() { + *x = WriteCondition_Clause{} + mi := &file_filer_subset_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *WriteCondition_Clause) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*WriteCondition_Clause) ProtoMessage() {} + +func (x *WriteCondition_Clause) ProtoReflect() protoreflect.Message { + mi := &file_filer_subset_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use WriteCondition_Clause.ProtoReflect.Descriptor instead. +func (*WriteCondition_Clause) Descriptor() ([]byte, []int) { + return file_filer_subset_proto_rawDescGZIP(), []int{9, 0} +} + +func (x *WriteCondition_Clause) GetKind() WriteCondition_Kind { + if x != nil { + return x.Kind + } + return WriteCondition_NONE +} + +func (x *WriteCondition_Clause) GetFids() []string { + if x != nil { + return x.Fids + } + return nil +} + var File_filer_subset_proto protoreflect.FileDescriptor const file_filer_subset_proto_rawDesc = "" + @@ -1530,7 +1684,15 @@ const file_filer_subset_proto_rawDesc = "" + "\x13CreateEntryResponse\x12\x14\n" + "\x05error\x18\x01 \x01(\tR\x05error\x123\n" + "\n" + - "error_code\x18\x03 \x01(\x0e2\x14.filer_pb.FilerErrorR\terrorCode\"\xd2\x02\n" + + "error_code\x18\x03 \x01(\x0e2\x14.filer_pb.FilerErrorR\terrorCode\"\xc3\x01\n" + + "\x0eWriteCondition\x129\n" + + "\aclauses\x18\x01 \x03(\v2\x1f.filer_pb.WriteCondition.ClauseR\aclauses\x1aO\n" + + "\x06Clause\x121\n" + + "\x04kind\x18\x01 \x01(\x0e2\x1d.filer_pb.WriteCondition.KindR\x04kind\x12\x12\n" + + "\x04fids\x18\t \x03(\tR\x04fids\"%\n" + + "\x04Kind\x12\b\n" + + "\x04NONE\x10\x00\x12\x13\n" + + "\x0fIF_CHUNKS_EQUAL\x10\t\"\x8a\x03\n" + "\x12UpdateEntryRequest\x12\x1c\n" + "\tdirectory\x18\x01 \x01(\tR\tdirectory\x12%\n" + "\x05entry\x18\x02 \x01(\v2\x0f.filer_pb.EntryR\x05entry\x121\n" + @@ -1538,7 +1700,8 @@ const file_filer_subset_proto_rawDesc = "" + "\n" + "signatures\x18\x04 \x03(\x05R\n" + "signatures\x12_\n" + - "\x11expected_extended\x18\x05 \x03(\v22.filer_pb.UpdateEntryRequest.ExpectedExtendedEntryR\x10expectedExtended\x1aC\n" + + "\x11expected_extended\x18\x05 \x03(\v22.filer_pb.UpdateEntryRequest.ExpectedExtendedEntryR\x10expectedExtended\x126\n" + + "\tcondition\x18\x06 \x01(\v2\x18.filer_pb.WriteConditionR\tcondition\x1aC\n" + "\x15ExpectedExtendedEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\fR\x05value:\x028\x01\"\x15\n" + @@ -1639,74 +1802,80 @@ func file_filer_subset_proto_rawDescGZIP() []byte { return file_filer_subset_proto_rawDescData } -var file_filer_subset_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_filer_subset_proto_msgTypes = make([]protoimpl.MessageInfo, 25) +var file_filer_subset_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_filer_subset_proto_msgTypes = make([]protoimpl.MessageInfo, 27) var file_filer_subset_proto_goTypes = []any{ (FilerError)(0), // 0: filer_pb.FilerError - (*LookupDirectoryEntryRequest)(nil), // 1: filer_pb.LookupDirectoryEntryRequest - (*LookupDirectoryEntryResponse)(nil), // 2: filer_pb.LookupDirectoryEntryResponse - (*ListEntriesRequest)(nil), // 3: filer_pb.ListEntriesRequest - (*ListEntriesResponse)(nil), // 4: filer_pb.ListEntriesResponse - (*Entry)(nil), // 5: filer_pb.Entry - (*FileChunk)(nil), // 6: filer_pb.FileChunk - (*FuseAttributes)(nil), // 7: filer_pb.FuseAttributes - (*CreateEntryRequest)(nil), // 8: filer_pb.CreateEntryRequest - (*CreateEntryResponse)(nil), // 9: filer_pb.CreateEntryResponse - (*UpdateEntryRequest)(nil), // 10: filer_pb.UpdateEntryRequest - (*UpdateEntryResponse)(nil), // 11: filer_pb.UpdateEntryResponse - (*DeleteEntryRequest)(nil), // 12: filer_pb.DeleteEntryRequest - (*DeleteEntryResponse)(nil), // 13: filer_pb.DeleteEntryResponse - (*AssignVolumeRequest)(nil), // 14: filer_pb.AssignVolumeRequest - (*AssignVolumeResponse)(nil), // 15: filer_pb.AssignVolumeResponse - (*LookupVolumeRequest)(nil), // 16: filer_pb.LookupVolumeRequest - (*Locations)(nil), // 17: filer_pb.Locations - (*Location)(nil), // 18: filer_pb.Location - (*LookupVolumeResponse)(nil), // 19: filer_pb.LookupVolumeResponse - (*GetFilerConfigurationRequest)(nil), // 20: filer_pb.GetFilerConfigurationRequest - (*GetFilerConfigurationResponse)(nil), // 21: filer_pb.GetFilerConfigurationResponse - nil, // 22: filer_pb.Entry.ExtendedEntry - nil, // 23: filer_pb.UpdateEntryRequest.ExpectedExtendedEntry - nil, // 24: filer_pb.DeleteEntryRequest.ExpectedExtendedEntry - nil, // 25: filer_pb.LookupVolumeResponse.LocationsMapEntry + (WriteCondition_Kind)(0), // 1: filer_pb.WriteCondition.Kind + (*LookupDirectoryEntryRequest)(nil), // 2: filer_pb.LookupDirectoryEntryRequest + (*LookupDirectoryEntryResponse)(nil), // 3: filer_pb.LookupDirectoryEntryResponse + (*ListEntriesRequest)(nil), // 4: filer_pb.ListEntriesRequest + (*ListEntriesResponse)(nil), // 5: filer_pb.ListEntriesResponse + (*Entry)(nil), // 6: filer_pb.Entry + (*FileChunk)(nil), // 7: filer_pb.FileChunk + (*FuseAttributes)(nil), // 8: filer_pb.FuseAttributes + (*CreateEntryRequest)(nil), // 9: filer_pb.CreateEntryRequest + (*CreateEntryResponse)(nil), // 10: filer_pb.CreateEntryResponse + (*WriteCondition)(nil), // 11: filer_pb.WriteCondition + (*UpdateEntryRequest)(nil), // 12: filer_pb.UpdateEntryRequest + (*UpdateEntryResponse)(nil), // 13: filer_pb.UpdateEntryResponse + (*DeleteEntryRequest)(nil), // 14: filer_pb.DeleteEntryRequest + (*DeleteEntryResponse)(nil), // 15: filer_pb.DeleteEntryResponse + (*AssignVolumeRequest)(nil), // 16: filer_pb.AssignVolumeRequest + (*AssignVolumeResponse)(nil), // 17: filer_pb.AssignVolumeResponse + (*LookupVolumeRequest)(nil), // 18: filer_pb.LookupVolumeRequest + (*Locations)(nil), // 19: filer_pb.Locations + (*Location)(nil), // 20: filer_pb.Location + (*LookupVolumeResponse)(nil), // 21: filer_pb.LookupVolumeResponse + (*GetFilerConfigurationRequest)(nil), // 22: filer_pb.GetFilerConfigurationRequest + (*GetFilerConfigurationResponse)(nil), // 23: filer_pb.GetFilerConfigurationResponse + nil, // 24: filer_pb.Entry.ExtendedEntry + (*WriteCondition_Clause)(nil), // 25: filer_pb.WriteCondition.Clause + nil, // 26: filer_pb.UpdateEntryRequest.ExpectedExtendedEntry + nil, // 27: filer_pb.DeleteEntryRequest.ExpectedExtendedEntry + nil, // 28: filer_pb.LookupVolumeResponse.LocationsMapEntry } var file_filer_subset_proto_depIdxs = []int32{ - 5, // 0: filer_pb.LookupDirectoryEntryResponse.entry:type_name -> filer_pb.Entry - 5, // 1: filer_pb.ListEntriesResponse.entry:type_name -> filer_pb.Entry - 6, // 2: filer_pb.Entry.chunks:type_name -> filer_pb.FileChunk - 7, // 3: filer_pb.Entry.attributes:type_name -> filer_pb.FuseAttributes - 22, // 4: filer_pb.Entry.extended:type_name -> filer_pb.Entry.ExtendedEntry - 5, // 5: filer_pb.CreateEntryRequest.entry:type_name -> filer_pb.Entry + 6, // 0: filer_pb.LookupDirectoryEntryResponse.entry:type_name -> filer_pb.Entry + 6, // 1: filer_pb.ListEntriesResponse.entry:type_name -> filer_pb.Entry + 7, // 2: filer_pb.Entry.chunks:type_name -> filer_pb.FileChunk + 8, // 3: filer_pb.Entry.attributes:type_name -> filer_pb.FuseAttributes + 24, // 4: filer_pb.Entry.extended:type_name -> filer_pb.Entry.ExtendedEntry + 6, // 5: filer_pb.CreateEntryRequest.entry:type_name -> filer_pb.Entry 0, // 6: filer_pb.CreateEntryResponse.error_code:type_name -> filer_pb.FilerError - 5, // 7: filer_pb.UpdateEntryRequest.entry:type_name -> filer_pb.Entry - 23, // 8: filer_pb.UpdateEntryRequest.expected_extended:type_name -> filer_pb.UpdateEntryRequest.ExpectedExtendedEntry - 24, // 9: filer_pb.DeleteEntryRequest.expected_extended:type_name -> filer_pb.DeleteEntryRequest.ExpectedExtendedEntry - 18, // 10: filer_pb.AssignVolumeResponse.location:type_name -> filer_pb.Location - 18, // 11: filer_pb.AssignVolumeResponse.replicas:type_name -> filer_pb.Location - 0, // 12: filer_pb.AssignVolumeResponse.error_code:type_name -> filer_pb.FilerError - 18, // 13: filer_pb.Locations.locations:type_name -> filer_pb.Location - 25, // 14: filer_pb.LookupVolumeResponse.locations_map:type_name -> filer_pb.LookupVolumeResponse.LocationsMapEntry - 17, // 15: filer_pb.LookupVolumeResponse.LocationsMapEntry.value:type_name -> filer_pb.Locations - 1, // 16: filer_pb.SeaweedFiler.LookupDirectoryEntry:input_type -> filer_pb.LookupDirectoryEntryRequest - 3, // 17: filer_pb.SeaweedFiler.ListEntries:input_type -> filer_pb.ListEntriesRequest - 8, // 18: filer_pb.SeaweedFiler.CreateEntry:input_type -> filer_pb.CreateEntryRequest - 10, // 19: filer_pb.SeaweedFiler.UpdateEntry:input_type -> filer_pb.UpdateEntryRequest - 12, // 20: filer_pb.SeaweedFiler.DeleteEntry:input_type -> filer_pb.DeleteEntryRequest - 14, // 21: filer_pb.SeaweedFiler.AssignVolume:input_type -> filer_pb.AssignVolumeRequest - 16, // 22: filer_pb.SeaweedFiler.LookupVolume:input_type -> filer_pb.LookupVolumeRequest - 20, // 23: filer_pb.SeaweedFiler.GetFilerConfiguration:input_type -> filer_pb.GetFilerConfigurationRequest - 2, // 24: filer_pb.SeaweedFiler.LookupDirectoryEntry:output_type -> filer_pb.LookupDirectoryEntryResponse - 4, // 25: filer_pb.SeaweedFiler.ListEntries:output_type -> filer_pb.ListEntriesResponse - 9, // 26: filer_pb.SeaweedFiler.CreateEntry:output_type -> filer_pb.CreateEntryResponse - 11, // 27: filer_pb.SeaweedFiler.UpdateEntry:output_type -> filer_pb.UpdateEntryResponse - 13, // 28: filer_pb.SeaweedFiler.DeleteEntry:output_type -> filer_pb.DeleteEntryResponse - 15, // 29: filer_pb.SeaweedFiler.AssignVolume:output_type -> filer_pb.AssignVolumeResponse - 19, // 30: filer_pb.SeaweedFiler.LookupVolume:output_type -> filer_pb.LookupVolumeResponse - 21, // 31: filer_pb.SeaweedFiler.GetFilerConfiguration:output_type -> filer_pb.GetFilerConfigurationResponse - 24, // [24:32] is the sub-list for method output_type - 16, // [16:24] is the sub-list for method input_type - 16, // [16:16] is the sub-list for extension type_name - 16, // [16:16] is the sub-list for extension extendee - 0, // [0:16] is the sub-list for field type_name + 25, // 7: filer_pb.WriteCondition.clauses:type_name -> filer_pb.WriteCondition.Clause + 6, // 8: filer_pb.UpdateEntryRequest.entry:type_name -> filer_pb.Entry + 26, // 9: filer_pb.UpdateEntryRequest.expected_extended:type_name -> filer_pb.UpdateEntryRequest.ExpectedExtendedEntry + 11, // 10: filer_pb.UpdateEntryRequest.condition:type_name -> filer_pb.WriteCondition + 27, // 11: filer_pb.DeleteEntryRequest.expected_extended:type_name -> filer_pb.DeleteEntryRequest.ExpectedExtendedEntry + 20, // 12: filer_pb.AssignVolumeResponse.location:type_name -> filer_pb.Location + 20, // 13: filer_pb.AssignVolumeResponse.replicas:type_name -> filer_pb.Location + 0, // 14: filer_pb.AssignVolumeResponse.error_code:type_name -> filer_pb.FilerError + 20, // 15: filer_pb.Locations.locations:type_name -> filer_pb.Location + 28, // 16: filer_pb.LookupVolumeResponse.locations_map:type_name -> filer_pb.LookupVolumeResponse.LocationsMapEntry + 1, // 17: filer_pb.WriteCondition.Clause.kind:type_name -> filer_pb.WriteCondition.Kind + 19, // 18: filer_pb.LookupVolumeResponse.LocationsMapEntry.value:type_name -> filer_pb.Locations + 2, // 19: filer_pb.SeaweedFiler.LookupDirectoryEntry:input_type -> filer_pb.LookupDirectoryEntryRequest + 4, // 20: filer_pb.SeaweedFiler.ListEntries:input_type -> filer_pb.ListEntriesRequest + 9, // 21: filer_pb.SeaweedFiler.CreateEntry:input_type -> filer_pb.CreateEntryRequest + 12, // 22: filer_pb.SeaweedFiler.UpdateEntry:input_type -> filer_pb.UpdateEntryRequest + 14, // 23: filer_pb.SeaweedFiler.DeleteEntry:input_type -> filer_pb.DeleteEntryRequest + 16, // 24: filer_pb.SeaweedFiler.AssignVolume:input_type -> filer_pb.AssignVolumeRequest + 18, // 25: filer_pb.SeaweedFiler.LookupVolume:input_type -> filer_pb.LookupVolumeRequest + 22, // 26: filer_pb.SeaweedFiler.GetFilerConfiguration:input_type -> filer_pb.GetFilerConfigurationRequest + 3, // 27: filer_pb.SeaweedFiler.LookupDirectoryEntry:output_type -> filer_pb.LookupDirectoryEntryResponse + 5, // 28: filer_pb.SeaweedFiler.ListEntries:output_type -> filer_pb.ListEntriesResponse + 10, // 29: filer_pb.SeaweedFiler.CreateEntry:output_type -> filer_pb.CreateEntryResponse + 13, // 30: filer_pb.SeaweedFiler.UpdateEntry:output_type -> filer_pb.UpdateEntryResponse + 15, // 31: filer_pb.SeaweedFiler.DeleteEntry:output_type -> filer_pb.DeleteEntryResponse + 17, // 32: filer_pb.SeaweedFiler.AssignVolume:output_type -> filer_pb.AssignVolumeResponse + 21, // 33: filer_pb.SeaweedFiler.LookupVolume:output_type -> filer_pb.LookupVolumeResponse + 23, // 34: filer_pb.SeaweedFiler.GetFilerConfiguration:output_type -> filer_pb.GetFilerConfigurationResponse + 27, // [27:35] is the sub-list for method output_type + 19, // [19:27] is the sub-list for method input_type + 19, // [19:19] is the sub-list for extension type_name + 19, // [19:19] is the sub-list for extension extendee + 0, // [0:19] is the sub-list for field type_name } func init() { file_filer_subset_proto_init() } @@ -1719,8 +1888,8 @@ func file_filer_subset_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_filer_subset_proto_rawDesc), len(file_filer_subset_proto_rawDesc)), - NumEnums: 1, - NumMessages: 25, + NumEnums: 2, + NumMessages: 27, NumExtensions: 0, NumServices: 1, }, diff --git a/seaweed-block/core/frontend/chunkstore/filerpb/filer_subset.proto b/seaweed-block/core/frontend/chunkstore/filerpb/filer_subset.proto index 601343588e..b051fdd106 100644 --- a/seaweed-block/core/frontend/chunkstore/filerpb/filer_subset.proto +++ b/seaweed-block/core/frontend/chunkstore/filerpb/filer_subset.proto @@ -102,12 +102,29 @@ message CreateEntryResponse { FilerError error_code = 3; } +// WriteCondition is copied from weed/pb/filer.proto (this repository): the +// IF_CHUNKS_EQUAL clause only. A filer that predates it drops field 6 of +// UpdateEntryRequest as unknown and applies the write unguarded, so the +// chunkstore decides at startup, by a probe, whether it is enforced. +message WriteCondition { + enum Kind { + NONE = 0; + IF_CHUNKS_EQUAL = 9; // fail unless the stored chunk fid multiset equals fids (absent entry = no chunks) + } + message Clause { + Kind kind = 1; + repeated string fids = 9; // chunk fid strings for IF_CHUNKS_EQUAL + } + repeated Clause clauses = 1; // all must hold (logical AND) +} + message UpdateEntryRequest { string directory = 1; Entry entry = 2; bool is_from_other_cluster = 3; repeated int32 signatures = 4; map expected_extended = 5; + WriteCondition condition = 6; } message UpdateEntryResponse { diff --git a/seaweed-block/core/frontend/chunkstore/head_readers_test.go b/seaweed-block/core/frontend/chunkstore/head_readers_test.go index fa7734b33b..170bf840cb 100644 --- a/seaweed-block/core/frontend/chunkstore/head_readers_test.go +++ b/seaweed-block/core/frontend/chunkstore/head_readers_test.go @@ -45,6 +45,7 @@ var headReaders = map[string]string{ "core/frontend/chunkstore/layout_verify.go verifyHead -> LookupEntry": "absent or unknown generation makes verify incomplete and suppresses MISSING/ORPHAN (TestVerifyLayoutRequiresStableHeadForMissingAndOrphans)", "core/frontend/chunkstore/layout_verify.go verifyHead -> DecodeLayoutHeadEntry": "invalid inline envelope supplies no generation and cannot confirm findings (TestVerifyLayoutRequiresStableHeadForMissingAndOrphans)", "core/frontend/chunkstore/startup_head_probe.go checkConditionalHead -> ReadHead": "absent/unreadable/changed disposable HEAD refuses startup; no volume HEAD is read (TestCatalogStartupRequiresWrongGenerationHeadRefusal)", + "core/frontend/chunkstore/startup_head_probe.go probeChunkCondition -> LookupEntry": "absent/unreadable disposable HEAD leaves the chunk guard off (page re-read only); no volume HEAD is read (TestCatalogStartupRequiresWrongGenerationHeadRefusal)", "cmd/blockvolume/chunk_maintenance.go newChunkMaintenance -> ReadHead": "diagnostic absent HEAD reports headGen0 and headGenError; it neither authorizes nor changes cleaning (TestMaintenanceStatusRealPassAndTimeout/head-absent)", "core/frontend/chunkstore/layout_remote.go ProbeSnapshots -> ReadHead": "absent or failed reads do not infer snapshot deletion; open local activity skips the read (TestMaintenanceNoticesSnapshotDeleteWithoutNotification, TestLayoutSnapshotProbeSkipsOpenActivityWithoutReadingHEAD)", "core/frontend/durable/provider_seal_replay.go readLayoutSeal -> ReadHead": "absent, unreadable and foreign layout proof refuse without cached success (TestLayoutPlainDetachReplayAfterRestartNeedsNoLegacyFactory)", diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete_intent.go b/seaweed-block/core/frontend/chunkstore/layout/delete_intent.go index 625fdf5dee..35cce3af77 100644 --- a/seaweed-block/core/frontend/chunkstore/layout/delete_intent.go +++ b/seaweed-block/core/frontend/chunkstore/layout/delete_intent.go @@ -172,6 +172,18 @@ func RunDeleteSnapshotWithIntent(ctx context.Context, st ListChainStore, base ui if !found || meta.Volume != h.VolumeID || meta.Session != deleteIntentWriter(base, ref) || meta.Mark != "" { return ErrPrecondition } + // Read the page again now that this run owns its tag. A stalled + // update from another run of the same delete can land between + // the read above and the adoption, putting a deleted page's data + // reference on this entry; once this run's tag is on it, no such + // update passes. An intent published over a page whose data is + // gone could never be consumed. The filer frees chunks from a + // deletion queue, so this sees only data already freed. + again := c + again.Ref = ref + if _, err := readListPage(ctx, st, h.VolumeID, again); err != nil { + return fmt.Errorf("%w: delete intent page changed during adoption: %w", ErrPrecondition, err) + } return nil }); err != nil { return Head{}, false, err diff --git a/seaweed-block/core/frontend/chunkstore/layout/delete_intent_reread_test.go b/seaweed-block/core/frontend/chunkstore/layout/delete_intent_reread_test.go new file mode 100644 index 0000000000..737d483b70 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/layout/delete_intent_reread_test.go @@ -0,0 +1,171 @@ +package layout + +import ( + "context" + "errors" + "fmt" + "testing" +) + +// staleUpdateBeforeAdoption is the store as the second run of a snapshot +// delete sees it when the first run's stalled page update lands between the +// second run's read of one page (rel) and its adoption: the page then +// carries the first run's writer tag, and its data is whatever the update +// left. This is a consequence-level projection of that update: it edits the +// tag and decides what a later read of the page returns (mode). The backend +// mechanism itself, a tag-conditional whole-entry update writing a deleted +// object's chunk reference over a re-created one, is exercised on the real +// store in package chunkstore: refused with the filer's chunk condition +// (TestAStaleMetadataChangeDoesNotOverwriteARecreatedObject), and landing +// without it (TestWithoutTheChunkGuardAStaleMetadataChangeOverwritesARecreatedObject). +type staleUpdateBeforeAdoption struct { + *chainStore + rel string + staleTag string + mode string // "freed": the read fails; "wrong": it returns other bytes; "deadline": the caller's deadline ends the read; "valid": the bytes are intact + wrong []byte + landed bool +} + +func (s *staleUpdateBeforeAdoption) Stat(ctx context.Context, rel string) (ObjectMeta, bool, error) { + if rel == s.rel && !s.landed { + s.landed = true + if o, ok := s.objs[s.full(rel)]; ok { + o.meta.Session = s.staleTag + } + } + return s.chainStore.Stat(ctx, rel) +} + +func (s *staleUpdateBeforeAdoption) ReadListPage(ctx context.Context, ref ListRef) ([]byte, bool, error) { + if rel, _ := ref.Path(); s.landed && rel == s.rel { + switch s.mode { + case "freed": + return nil, false, errors.New("the page's data was freed") + case "wrong": + return append([]byte(nil), s.wrong...), true, nil + case "deadline": + return nil, false, fmt.Errorf("lookup: %w", context.DeadlineExceeded) + } + } + return s.chainStore.ReadListPage(ctx, ref) +} + +// rerunFixture stages a snapshot delete's intent at the first base, lets a +// cleaning pass delete the unlinked pages, and stages them again at the new +// base: the second run. With twoPages the intent has two pages and the +// stale update hits the later one, the second page the chain visits. +func rerunFixture(t *testing.T, twoPages bool) (s *chainStore, c ListCursor, hit ListRef, other []byte, firstBase, secondBase uint64) { + t.Helper() + ctx := context.Background() + s, c, p := deleteIntentFixture(t) + firstBase = s.h.Gen + pages := []ListPage{p} + if twoPages { + tail := p + tail.Entries = p.Entries[1:] + tailRef, err := tail.Ref() + if err != nil { + t.Fatal(err) + } + head := p + head.Entries = p.Entries[:1] + head.Pages = 2 + head.Next = &tailRef + headRef, err := head.Ref() + if err != nil { + t.Fatal(err) + } + pages = []ListPage{tail, head} + c.Ref = headRef + } + stage := func(base uint64) { + for _, pg := range pages { + if _, err := StageSnapshotDeletePage(ctx, s, base, pg); err != nil { + t.Fatal(err) + } + } + } + stage(firstBase) + s.h.Gen = firstBase + 2 // a cleaning pass + for _, pg := range pages { + ref, _ := pg.Ref() + rel, _ := ref.Path() + delete(s.objs, s.full(rel)) + } + secondBase = s.h.Gen + stage(secondBase) + hit, _ = pages[0].Ref() // the only page, or the tail: the later page visited + for _, pg := range pages { + if ref, _ := pg.Ref(); ref != hit { + other, _, _ = s.ReadListPage(ctx, ref) + } + } + if other == nil { + other = []byte(`{"pages":1,"entries":["not this page"]}`) + } + return s, c, hit, other, firstBase, secondBase +} + +// The second run of a snapshot delete must not publish an intent whose page +// lost its data, or holds other bytes, after a stalled update from the first +// run landed between the second run's read of the page and its adoption. +// The refusal comes after the adoption (the page carries this run's tag), is +// a precondition, and writes nothing to HEAD: the snapshot stays. The same +// schedule with the page's bytes intact publishes. +func TestASnapshotDeleteIsNotPublishedOverAPageWhoseDataWasFreed(t *testing.T) { + for _, tc := range []struct { + name string + mode string + twoPages bool + publish bool + cause error + }{ + {"freed, one page", "freed", false, false, nil}, + {"other bytes, one page", "wrong", false, false, nil}, + {"freed, the later of two pages", "freed", true, false, nil}, + {"other bytes, the later of two pages", "wrong", true, false, nil}, + {"the caller's deadline ends the re-read", "deadline", false, false, context.DeadlineExceeded}, + {"intact bytes after the stale tag, one page", "valid", false, true, nil}, + {"intact bytes after the stale tag, two pages", "valid", true, true, nil}, + } { + t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() + s, c, hit, other, firstBase, secondBase := rerunFixture(t, tc.twoPages) + rel, err := hit.Path() + if err != nil { + t.Fatal(err) + } + st := &staleUpdateBeforeAdoption{chainStore: s, rel: rel, staleTag: deleteIntentWriter(firstBase, hit), mode: tc.mode, wrong: other} + updates := s.updates + _, publishErr := RunDeleteSnapshotWithIntent(ctx, st, secondBase, c) + if !st.landed { + t.Fatal("fixture: the stale update never landed (the adoption did not Stat the page)") + } + if tc.publish { + if publishErr != nil || s.h.List == nil { + t.Fatalf("an intact page after the stale tag did not publish: %v, list %+v", publishErr, s.h.List) + } + if _, kept := s.h.Snapshots["daily"]; kept { + t.Fatal("published, but the snapshot is still named") + } + return + } + if !errors.Is(publishErr, ErrPrecondition) { + t.Fatalf("publishing over a page whose data changed answered %v, want ErrPrecondition", publishErr) + } + if tc.cause != nil && !errors.Is(publishErr, tc.cause) { + t.Fatalf("the refusal dropped the re-read's cause: %v, want it to keep %v", publishErr, tc.cause) + } + if s.h.List != nil || s.updates != updates { + t.Fatalf("the refusal wrote HEAD: list %+v, %d update(s)", s.h.List, s.updates-updates) + } + if snap, kept := s.h.Snapshots["daily"]; !kept || snap.Gen != 4 { + t.Fatalf("the refusal did not keep the snapshot: %+v (kept %v)", snap, kept) + } + if meta, found, _ := s.Stat(ctx, rel); !found || meta.Session != deleteIntentWriter(secondBase, hit) { + t.Fatalf("the refusal came before the adoption: the page's tag is %+v, want this run's %q", meta, deleteIntentWriter(secondBase, hit)) + } + }) + } +} diff --git a/seaweed-block/core/frontend/chunkstore/layout_change_meta_recreated_test.go b/seaweed-block/core/frontend/chunkstore/layout_change_meta_recreated_test.go new file mode 100644 index 0000000000..666d2d54b1 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/layout_change_meta_recreated_test.go @@ -0,0 +1,218 @@ +package chunkstore + +import ( + "bytes" + "context" + "errors" + "sync" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +// betweenLookupAndUpdate runs before, once, ahead of the first update: what +// other writers do while a stale one is between its lookup and its +// conditional update. It forwards the chunk condition, so a store over it can +// run with the guard on. +type betweenLookupAndUpdate struct { + Filer + once sync.Once + before func() +} + +func (f *betweenLookupAndUpdate) UpdateEntry(ctx context.Context, dir string, e *filerpb.Entry, expected map[string][]byte) error { + f.once.Do(f.before) + return f.Filer.UpdateEntry(ctx, dir, e, expected) +} + +func (f *betweenLookupAndUpdate) UpdateEntryIfChunks(ctx context.Context, dir string, e *filerpb.Entry, expected map[string][]byte, fids []string) error { + f.once.Do(f.before) + return f.Filer.(ChunkConditionFiler).UpdateEntryIfChunks(ctx, dir, e, expected, fids) +} + +// recreatedObject is one object that a stale writer looked up, then (while +// the writer was between its lookup and its update) a cleaner marked and +// deleted, and another executor of the same operation created again with the +// same producer tag and a new chunk. +type recreatedObject struct { + f *fakeFiler + others, stale *LayoutStore + rel string + meta layout.ObjectMeta + first, second string + fid func() (string, bool) +} + +func newRecreatedObject(t *testing.T, guard bool) *recreatedObject { + t.Helper() + ctx := context.Background() + f, b := newFakeFiler(), newFakeBlobs() + var id layout.VolumeID + for i := range id { + id[i] = 0x30 + byte(i) + } + others, err := NewLayoutStore(f, b, "/vol", id) + if err != nil { + t.Fatal(err) + } + hooked := &betweenLookupAndUpdate{Filer: f} + stale, err := NewLayoutStore(hooked, b, "/vol", id) + if err != nil { + t.Fatal(err) + } + stale.SetChunkGuard(guard) + data := bytes.Repeat([]byte{0x5a}, 4096) + o := &recreatedObject{f: f, others: others, stale: stale, rel: layout.NameChunk(1, data).Path()} + dir, name, err := others.object(o.rel) + if err != nil { + t.Fatal(err) + } + o.fid = func() (string, bool) { + e, err := f.LookupEntry(ctx, dir, name) + if errors.Is(err, ErrNotFound) { + return "", false + } + if err != nil || len(e.Chunks) != 1 { + t.Fatalf("lookup %s: %+v %v", o.rel, e, err) + } + return e.Chunks[0].FileId, true + } + if err := others.Create(ctx, o.rel, data, "producer-1"); err != nil { + t.Fatal(err) + } + o.first, _ = o.fid() + meta, found, err := others.Stat(ctx, o.rel) + if err != nil || !found { + t.Fatalf("stat: %v %v", found, err) + } + o.meta = meta + hooked.before = func() { + if err := others.Mark(ctx, o.rel, meta, "clean-1"); err != nil { + t.Errorf("mark: %v", err) + } + if err := others.DeleteMarked(ctx, o.rel, "clean-1"); err != nil { + t.Errorf("delete: %v", err) + } + if err := others.Create(ctx, o.rel, data, "producer-1"); err != nil { + t.Errorf("re-create: %v", err) + } + o.second, _ = o.fid() + } + return o +} + +func (o *recreatedObject) checkRecreated(t *testing.T) { + t.Helper() + if o.second == "" || o.second == o.first { + t.Fatalf("fixture: the object was not re-created with a new chunk (first %s, second %s)", o.first, o.second) + } +} + +// A stale metadata change (a delete-intent page's adoption by an executor +// that paused between its lookup and its update) must not write the entry it +// looked up over an object deleted and created again with the same tags in +// between: the update would put the deleted object's chunk on the new entry, +// and the filer would free the new entry's chunk. With the filer's chunk +// condition the write is refused, since a re-created object has a new chunk. +func TestAStaleMetadataChangeDoesNotOverwriteARecreatedObject(t *testing.T) { + o := newRecreatedObject(t, true) + err := o.stale.Reuse(context.Background(), o.rel, o.meta, "writer-1") + o.checkRecreated(t) + if !errors.Is(err, layout.ErrPrecondition) { + t.Fatalf("the stale update over a re-created object answered %v, want ErrPrecondition", err) + } + if got, _ := o.fid(); got != o.second { + t.Fatalf("the stale update wrote chunk %s over the re-created object's %s", got, o.second) + } +} + +// With the guard on, a metadata change of an object nobody touched since its +// lookup still lands: adoption retags it, and a cleaner marks and deletes it. +func TestWithTheChunkGuardAnUnchangedObjectIsStillAdoptedMarkedAndDeleted(t *testing.T) { + ctx := context.Background() + f, b := newFakeFiler(), newFakeBlobs() + var id layout.VolumeID + for i := range id { + id[i] = 0x40 + byte(i) + } + st, err := NewLayoutStore(f, b, "/vol", id) + if err != nil { + t.Fatal(err) + } + st.SetChunkGuard(true) + data := bytes.Repeat([]byte{0x3c}, 4096) + rel := layout.NameChunk(1, data).Path() + if err := st.Create(ctx, rel, data, "producer-1"); err != nil { + t.Fatal(err) + } + meta, _, err := st.Stat(ctx, rel) + if err != nil { + t.Fatal(err) + } + if err := st.Reuse(ctx, rel, meta, "writer-1"); err != nil { + t.Fatalf("guarded adoption of an unchanged object: %v", err) + } + if meta, _, err = st.Stat(ctx, rel); err != nil || meta.Session != "writer-1" { + t.Fatalf("after adoption: %+v %v", meta, err) + } + if err := st.Mark(ctx, rel, meta, "clean-1"); err != nil { + t.Fatalf("guarded mark of an unchanged object: %v", err) + } + if err := st.DeleteMarked(ctx, rel, "clean-1"); err != nil { + t.Fatalf("delete: %v", err) + } + if _, found, err := st.Stat(ctx, rel); err != nil || found { + t.Fatalf("the marked object was not deleted: found %v %v", found, err) + } +} + +// A cleaner that looked up an object to mark it, then paused, must not +// delete the object created again in between: its mark is refused, so its +// delete (which expects that mark) is refused too. +func TestAStaleCleanerMarkDoesNotDeleteARecreatedObject(t *testing.T) { + o := newRecreatedObject(t, true) + ctx := context.Background() + markErr := o.stale.Mark(ctx, o.rel, o.meta, "clean-2") + o.checkRecreated(t) + if !errors.Is(markErr, layout.ErrPrecondition) { + t.Fatalf("the stale mark over a re-created object answered %v, want ErrPrecondition", markErr) + } + if err := o.stale.DeleteMarked(ctx, o.rel, "clean-2"); !errors.Is(err, layout.ErrPrecondition) { + t.Fatalf("deleting under the refused mark answered %v, want ErrPrecondition", err) + } + if got, found := o.fid(); !found || got != o.second { + t.Fatalf("the re-created object is gone or changed: chunk %q found %v, want %s", got, found, o.second) + } +} + +// Without the chunk condition (a filer that does not enforce it) both stale +// writes land: the store behavior the delete intent page re-read exists for, +// kept visible here. +func TestWithoutTheChunkGuardAStaleMetadataChangeOverwritesARecreatedObject(t *testing.T) { + t.Run("adoption", func(t *testing.T) { + o := newRecreatedObject(t, false) + err := o.stale.Reuse(context.Background(), o.rel, o.meta, "writer-1") + o.checkRecreated(t) + if err != nil { + t.Fatalf("the unguarded stale update was refused (%v)", err) + } + if got, _ := o.fid(); got != o.first { + t.Fatalf("the unguarded stale update left chunk %s, want the deleted object's %s", got, o.first) + } + }) + t.Run("cleaner", func(t *testing.T) { + o := newRecreatedObject(t, false) + ctx := context.Background() + if err := o.stale.Mark(ctx, o.rel, o.meta, "clean-2"); err != nil { + t.Fatalf("the unguarded stale mark was refused (%v)", err) + } + o.checkRecreated(t) + if err := o.stale.DeleteMarked(ctx, o.rel, "clean-2"); err != nil { + t.Fatalf("delete: %v", err) + } + if _, found := o.fid(); found { + t.Fatal("the unguarded stale mark did not lead to the re-created object's deletion") + } + }) +} diff --git a/seaweed-block/core/frontend/chunkstore/layout_store.go b/seaweed-block/core/frontend/chunkstore/layout_store.go index 2b15656a03..05eee901d7 100644 --- a/seaweed-block/core/frontend/chunkstore/layout_store.go +++ b/seaweed-block/core/frontend/chunkstore/layout_store.go @@ -36,6 +36,9 @@ type LayoutStore struct { b Blobs root string id layout.VolumeID + // chunkGuard: the filer enforces IF_CHUNKS_EQUAL (the startup probe said + // so), and metadata changes send the looked-up entry's chunk fids with it. + chunkGuard bool } func NewLayoutStore(f Filer, b Blobs, root string, id layout.VolumeID) (*LayoutStore, error) { @@ -362,9 +365,28 @@ func (s *LayoutStore) changeMeta(ctx context.Context, rel string, expect layout. e.Extended[layoutMark] = []byte(mark) // Preserve the original FileChunks: an UpdateEntry dropping them // would tell the filer to delete the object's immutable data. + // + // The update writes the whole looked-up entry back, chunks included, and + // its tags alone do not tell this object from one deleted and created + // again with the same tags since the lookup: written over that one, the + // update would put the deleted object's chunks on it and the filer would + // free the new chunks. A re-created object always has new chunks, so the + // filer's chunk condition refuses that write. Without it (a filer that + // does not enforce the condition), delete intent publication re-reads + // each adopted page instead (layout.RunDeleteSnapshotWithIntent). + if cf, ok := s.f.(ChunkConditionFiler); ok && s.chunkGuard { + return layoutError(cf.UpdateEntryIfChunks(ctx, dir, e, objectExpected(expect), entryFids(e))) + } return layoutError(s.f.UpdateEntry(ctx, dir, e, objectExpected(expect))) } +// SetChunkGuard turns the filer chunk condition on or off for this store's +// metadata changes; BCatalog sets it from its startup probe. +func (s *LayoutStore) SetChunkGuard(on bool) { s.chunkGuard = on } + +// ChunkGuard reports whether metadata changes send the chunk condition. +func (s *LayoutStore) ChunkGuard() bool { return s.chunkGuard } + func (s *LayoutStore) Reuse(ctx context.Context, rel string, expect layout.ObjectMeta, session string) error { if session == "" { return errors.New("chunkstore: reuse needs a session") diff --git a/seaweed-block/core/frontend/chunkstore/memfiler.go b/seaweed-block/core/frontend/chunkstore/memfiler.go index 412cc12553..b9c99e9440 100644 --- a/seaweed-block/core/frontend/chunkstore/memfiler.go +++ b/seaweed-block/core/frontend/chunkstore/memfiler.go @@ -63,6 +63,23 @@ func (m *MemFiler) UpdateEntry(_ context.Context, dir string, e *filerpb.Entry, return nil } +// UpdateEntryIfChunks is UpdateEntry that also requires the stored chunk +// fids to equal fids as a multiset, as the filer's IF_CHUNKS_EQUAL does. +func (m *MemFiler) UpdateEntryIfChunks(_ context.Context, dir string, e *filerpb.Entry, expected map[string][]byte, fids []string) error { + m.mu.Lock() + defer m.mu.Unlock() + p := path.Join(dir, e.GetName()) + cur, ok := m.e[p] + if !ok { + return ErrNotFound + } + if !extendedMatch(cur, expected) || !fidsEqual(entryFids(cur), fids) { + return ErrPrecondition + } + m.e[p] = proto.Clone(e).(*filerpb.Entry) + return nil +} + func (m *MemFiler) ListEntries(_ context.Context, dir, prefix, startAfter string, limit uint32) ([]*filerpb.Entry, error) { m.mu.Lock() defer m.mu.Unlock() diff --git a/seaweed-block/core/frontend/chunkstore/remote.go b/seaweed-block/core/frontend/chunkstore/remote.go index f588d3e397..f8fd406d70 100644 --- a/seaweed-block/core/frontend/chunkstore/remote.go +++ b/seaweed-block/core/frontend/chunkstore/remote.go @@ -35,6 +35,49 @@ type Filer interface { DeleteEntry(ctx context.Context, dir, name string, expected map[string][]byte) error } +// ChunkConditionFiler is a Filer that can also send the filer's +// IF_CHUNKS_EQUAL write condition: UpdateEntryIfChunks applies e only if every +// expected extended key still holds its value AND the stored entry's chunk +// fids still equal fids as a multiset; otherwise ErrPrecondition. A filer +// that predates the condition drops it and applies the write unguarded, which +// only a probe can tell (BCatalog.checkConditionalHead); a wrapper that does +// not forward this method is treated the same way. +type ChunkConditionFiler interface { + UpdateEntryIfChunks(ctx context.Context, dir string, e *filerpb.Entry, expected map[string][]byte, fids []string) error +} + +// chunksEqual is the filer write condition that the stored chunk fids equal +// fids as a multiset (no fids: the entry has no chunks). +func chunksEqual(fids []string) *filerpb.WriteCondition { + return &filerpb.WriteCondition{Clauses: []*filerpb.WriteCondition_Clause{{Kind: filerpb.WriteCondition_IF_CHUNKS_EQUAL, Fids: fids}}} +} + +// entryFids is the multiset of e's chunk fids, in its order. +func entryFids(e *filerpb.Entry) []string { + fids := make([]string, 0, len(e.GetChunks())) + for _, c := range e.GetChunks() { + fids = append(fids, c.GetFileId()) + } + return fids +} + +// fidsEqual compares two fid lists as multisets, as the filer does. +func fidsEqual(a, b []string) bool { + if len(a) != len(b) { + return false + } + n := make(map[string]int, len(a)) + for _, f := range a { + n[f]++ + } + for _, f := range b { + if n[f]--; n[f] < 0 { + return false + } + } + return true +} + // Blobs stores immutable chunk payloads as SeaweedFS needles. type Blobs interface { // Put stores data as a new needle and returns its fid. A fid is never diff --git a/seaweed-block/core/frontend/chunkstore/startup_chunk_condition_probe_test.go b/seaweed-block/core/frontend/chunkstore/startup_chunk_condition_probe_test.go new file mode 100644 index 0000000000..4a7b0f30c8 --- /dev/null +++ b/seaweed-block/core/frontend/chunkstore/startup_chunk_condition_probe_test.go @@ -0,0 +1,80 @@ +package chunkstore + +import ( + "context" + "errors" + "testing" + + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/filerpb" + "github.com/seaweedfs/seaweed-block/core/frontend/chunkstore/layout" +) + +// hidesChunkCondition is a Filer wrapper that does not forward +// UpdateEntryIfChunks: to the probe it is a filer without the condition. +type hidesChunkCondition struct{ Filer } + +// chunkProbeFails answers every conditional update with err (the HEAD gate, +// an unconditional update, is unaffected): no definite refusal. +type chunkProbeFails struct { + *fakeFiler + err error +} + +func (f chunkProbeFails) UpdateEntryIfChunks(context.Context, string, *filerpb.Entry, map[string][]byte, []string) error { + return f.err +} + +// The startup probe decides the metadata change guard from the filer's +// answer alone: a filer that refuses a mismatched IF_CHUNKS_EQUAL update turns +// the guard on for every store the catalog opens; a filer that drops the +// condition (or a client that cannot send it) leaves the page re-read as the +// only check. No version string is read. +func TestTheStartupProbeTurnsTheChunkGuardOnOnlyForAFilerThatEnforcesIt(t *testing.T) { + for _, tc := range []struct { + name string + filer func() Filer + guard string + storeG bool + }{ + {"a filer that enforces the condition", func() Filer { return newFakeFiler() }, MetadataGuardChunks, true}, + {"a filer that drops the condition", func() Filer { f := newFakeFiler(); f.ignoreChunkCondition = true; return f }, MetadataGuardReread, false}, + {"a client wrapper that cannot send it", func() Filer { return hidesChunkCondition{newFakeFiler()} }, MetadataGuardReread, false}, + // Enforcement not established: the probe got no definite refusal. + {"a probe that times out", func() Filer { return chunkProbeFails{newFakeFiler(), context.DeadlineExceeded} }, MetadataGuardReread, false}, + {"a probe whose answer is lost", func() Filer { return chunkProbeFails{newFakeFiler(), errors.New("transport: lost answer")} }, MetadataGuardReread, false}, + {"a probe whose entry vanished", func() Filer { return chunkProbeFails{newFakeFiler(), ErrNotFound} }, MetadataGuardReread, false}, + } { + t.Run(tc.name, func(t *testing.T) { + cat, err := NewBCatalog(tc.filer(), newFakeBlobs(), "/blocks") + if err != nil { + t.Fatal(err) + } + if err := cat.checkConditionalHead(context.Background()); err != nil { + t.Fatalf("the conditional HEAD probe failed: %v", err) + } + if got := cat.MetadataGuard(); got != tc.guard { + t.Fatalf("metadata guard %q, want %q", got, tc.guard) + } + id, err := layout.NewVolumeID() + if err != nil { + t.Fatal(err) + } + v := VolumeRef{Name: "v1", ID: id} + st, err := cat.Store(v) + if err != nil { + t.Fatal(err) + } + if st.ChunkGuard() != tc.storeG { + t.Fatalf("a store opened by the catalog has chunk guard %v, want %v", st.ChunkGuard(), tc.storeG) + } + // /status/chunk answers the catalog's usage: it names the guard. + ctx := context.Background() + if _, err := cat.CreateVolume(ctx, v, layout.Geometry{SizeBytes: 64 * 4096, BlockSize: 4096, ChunkBytes: 4 * 4096}); err != nil { + t.Fatal(err) + } + if u, err := cat.Usage(ctx, v); err != nil || u.MetadataGuard != tc.guard { + t.Fatalf("usage names guard %q (%v), want %q", u.MetadataGuard, err, tc.guard) + } + }) + } +} diff --git a/seaweed-block/core/frontend/chunkstore/startup_head_probe.go b/seaweed-block/core/frontend/chunkstore/startup_head_probe.go index cf6ae98aa6..a02fdfec26 100644 --- a/seaweed-block/core/frontend/chunkstore/startup_head_probe.go +++ b/seaweed-block/core/frontend/chunkstore/startup_head_probe.go @@ -152,5 +152,34 @@ func (c *BCatalog) checkConditionalHead(ctx context.Context) error { if err != nil || !bytes.Equal(before, after) { return fmt.Errorf("%w: wrong-generation update changed %s", ErrConditionalHead, root) } + c.chunkGuard = probeChunkCondition(ctx, c.f, root) + log.Printf("chunkstore: metadata change guard: %s", c.MetadataGuard()) return nil } + +// probeChunkCondition asks the filer to rewrite the disposable probe HEAD +// only if it holds a chunk it does not have. A filer that enforces +// IF_CHUNKS_EQUAL refuses; one that predates it drops the unknown field and +// applies the write (the same entry, in a directory nothing else reads). +// Only a definite refusal turns the guard on; anything else leaves the +// page re-read as the only check. No version string is consulted. +func probeChunkCondition(ctx context.Context, f Filer, root string) bool { + cf, ok := f.(ChunkConditionFiler) + if !ok { + return false + } + e, err := f.LookupEntry(ctx, root, layout.HeadName) + if err != nil { + log.Printf("chunkstore: WARNING chunk condition probe: read %s: %v", root, err) + return false + } + absent := append(entryFids(e), "0,"+strings.TrimPrefix(path.Base(root), startupProbePrefix)) + err = cf.UpdateEntryIfChunks(ctx, root, e, nil, absent) + if errors.Is(err, ErrPrecondition) { + return true + } + if err != nil { + log.Printf("chunkstore: WARNING chunk condition probe: update %s: %v", root, err) + } + return false +} diff --git a/seaweed-block/core/frontend/chunkstore/startup_head_probe_test.go b/seaweed-block/core/frontend/chunkstore/startup_head_probe_test.go index cc3a439562..a9f3615a57 100644 --- a/seaweed-block/core/frontend/chunkstore/startup_head_probe_test.go +++ b/seaweed-block/core/frontend/chunkstore/startup_head_probe_test.go @@ -23,8 +23,13 @@ type conditionalProbeServer struct { configFiler store *fakeFiler mode string - updates int - creates []*filerpb.CreateEntryRequest + updates int // updates without a write condition: the wrong-generation exchange + // chunkProbes counts updates carrying a write condition: the chunk + // condition probe. Only mode conditional-chunk-filer enforces it; the + // other modes drop it, as a filer that predates it does. + chunkProbes int + headReadsAfterUpdate int + creates []*filerpb.CreateEntryRequest } func (f *conditionalProbeServer) CreateEntry(ctx context.Context, r *filerpb.CreateEntryRequest) (*filerpb.CreateEntryResponse, error) { @@ -38,9 +43,42 @@ func (f *conditionalProbeServer) CreateEntry(ctx context.Context, r *filerpb.Cre } func (f *conditionalProbeServer) UpdateEntry(ctx context.Context, r *filerpb.UpdateEntryRequest) (*filerpb.UpdateEntryResponse, error) { f.mu.Lock() - f.updates++ + if r.GetCondition() != nil { + f.chunkProbes++ + } else { + f.updates++ + } mode := f.mode f.mu.Unlock() + if r.GetCondition() != nil { + // The HEAD gate passed; only the chunk condition probe fails here. + switch mode { + case "chunk-probe-unavailable": + return nil, status.Error(codes.Unavailable, "lost answer") + case "chunk-probe-deadline": + return nil, status.Error(codes.DeadlineExceeded, "no answer in time") + case "chunk-probe-internal": + return nil, status.Error(codes.Internal, "filer error") + case "chunk-probe-not-found": + return nil, status.Error(codes.NotFound, "update target absent") + } + } + if mode == "conditional-chunk-filer" && r.GetCondition() != nil { + var fids []string + for _, c := range r.GetCondition().GetClauses() { + if c.GetKind() != filerpb.WriteCondition_IF_CHUNKS_EQUAL { + return nil, status.Error(codes.InvalidArgument, "unexpected clause") + } + fids = append(fids, c.GetFids()...) + } + if err := f.store.UpdateEntryIfChunks(ctx, r.Directory, r.Entry, r.ExpectedExtended, fids); err != nil { + if errors.Is(err, ErrPrecondition) { + return nil, status.Error(codes.FailedPrecondition, err.Error()) + } + return nil, status.Error(codes.Internal, err.Error()) + } + return &filerpb.UpdateEntryResponse{}, nil + } if mode == "not-found" { return nil, status.Error(codes.NotFound, "update target absent") } @@ -64,6 +102,17 @@ func (f *conditionalProbeServer) UpdateEntry(ctx context.Context, r *filerpb.Upd return &filerpb.UpdateEntryResponse{}, nil } func (f *conditionalProbeServer) LookupDirectoryEntry(ctx context.Context, r *filerpb.LookupDirectoryEntryRequest) (*filerpb.LookupDirectoryEntryResponse, error) { + f.mu.Lock() + if r.Name == layout.HeadName && f.updates > 0 { + f.headReadsAfterUpdate++ + } + failProbeRead := f.mode == "chunk-probe-lookup-error" && f.headReadsAfterUpdate == 2 + f.mu.Unlock() + // After the wrong-generation exchange the gate confirms HEAD (first read); + // the second read is the chunk condition probe's. + if failProbeRead { + return nil, status.Error(codes.Unavailable, "lookup lost") + } e, err := f.store.LookupEntry(ctx, r.Directory, r.Name) if err != nil { return nil, status.Error(codes.NotFound, err.Error()) @@ -95,7 +144,9 @@ func (f *conditionalProbeServer) DeleteEntry(ctx context.Context, r *filerpb.Del return &filerpb.DeleteEntryResponse{}, nil } func TestCatalogStartupRequiresWrongGenerationHeadRefusal(t *testing.T) { - for _, mode := range []string{"ignores-conditions", "mutates-then-refuses", "transport-error", "not-found", "conditional-filer", "cleanup-head-error", "cleanup-dir-error"} { + for _, mode := range []string{"ignores-conditions", "mutates-then-refuses", "transport-error", "not-found", "conditional-filer", "conditional-chunk-filer", "cleanup-head-error", "cleanup-dir-error", + // The HEAD gate passes; the chunk condition probe gets no definite refusal. + "chunk-probe-unavailable", "chunk-probe-deadline", "chunk-probe-internal", "chunk-probe-not-found", "chunk-probe-lookup-error"} { t.Run(mode, func(t *testing.T) { var logs bytes.Buffer previous := log.Writer() @@ -120,7 +171,8 @@ func TestCatalogStartupRequiresWrongGenerationHeadRefusal(t *testing.T) { if client != nil { defer client.Close() } - if mode != "conditional-filer" && !strings.HasPrefix(mode, "cleanup-") { + admitted := mode == "conditional-filer" || mode == "conditional-chunk-filer" || strings.HasPrefix(mode, "cleanup-") || strings.HasPrefix(mode, "chunk-probe-") + if !admitted { if !errors.Is(err, ErrConditionalHead) || cat != nil || !strings.Contains(err.Error(), "conditional HEAD") { t.Fatalf("broken conditional startup: cat=%v err=%v", cat, err) } @@ -131,9 +183,36 @@ func TestCatalogStartupRequiresWrongGenerationHeadRefusal(t *testing.T) { t.Fatalf("cleanup warning missing: %s", logs.String()) } f.mu.Lock() - updates := f.updates + updates, chunkProbes := f.updates, f.chunkProbes creates := append([]*filerpb.CreateEntryRequest(nil), f.creates...) f.mu.Unlock() + // An admitted startup sends one chunk condition probe, over the + // real client, and keeps the guard on only if the filer refused it. + wantProbes, wantGuard := 0, "" + if admitted { + wantProbes, wantGuard = 1, MetadataGuardReread + if mode == "chunk-probe-lookup-error" { + wantProbes = 0 // the probe could not read HEAD, so it sent nothing + } + if mode == "conditional-chunk-filer" { + wantGuard = MetadataGuardChunks + } + } + if chunkProbes != wantProbes { + t.Fatalf("chunk condition probes=%d want %d", chunkProbes, wantProbes) + } + if admitted && cat.MetadataGuard() != wantGuard { + t.Fatalf("metadata guard %q want %q", cat.MetadataGuard(), wantGuard) + } + if admitted && !strings.Contains(logs.String(), "metadata change guard: "+wantGuard) { + t.Fatalf("the startup log does not name the guard %q: %s", wantGuard, logs.String()) + } + if admitted { + st, err := cat.Store(VolumeRef{Name: "v1", ID: layout.VolumeID{1}}) + if err != nil || st.ChunkGuard() != (wantGuard == MetadataGuardChunks) { + t.Fatalf("a store the catalog opens has chunk guard %v (%v), want %v", st.ChunkGuard(), err, wantGuard == MetadataGuardChunks) + } + } // This mint is a disposable HEAD label, not an alternate volume // creator. No VOLUME, lifecycle identity or real volume root is used. if len(creates) != 1 { diff --git a/seaweed-block/core/frontend/chunkstore/swfs.go b/seaweed-block/core/frontend/chunkstore/swfs.go index 23941589bd..6e9c738323 100644 --- a/seaweed-block/core/frontend/chunkstore/swfs.go +++ b/seaweed-block/core/frontend/chunkstore/swfs.go @@ -160,8 +160,19 @@ func (c *SWFS) CreateEntry(ctx context.Context, dir string, e *filerpb.Entry, oE // FailedPrecondition. Any other error is ambiguous (the write may or may not // have applied) and is returned unwrapped from the sentinels. func (c *SWFS) UpdateEntry(ctx context.Context, dir string, e *filerpb.Entry, expected map[string][]byte) error { + return c.updateEntry(ctx, dir, e, expected, nil) +} + +// UpdateEntryIfChunks implements ChunkConditionFiler: UpdateEntry that also +// sends the filer's IF_CHUNKS_EQUAL condition with fids. A failed condition +// comes back as gRPC FailedPrecondition, like a failed expected_extended. +func (c *SWFS) UpdateEntryIfChunks(ctx context.Context, dir string, e *filerpb.Entry, expected map[string][]byte, fids []string) error { + return c.updateEntry(ctx, dir, e, expected, chunksEqual(fids)) +} + +func (c *SWFS) updateEntry(ctx context.Context, dir string, e *filerpb.Entry, expected map[string][]byte, cond *filerpb.WriteCondition) error { return maintenanceError(ctx, func(ctx context.Context) error { - _, err := c.fc.UpdateEntry(ctx, &filerpb.UpdateEntryRequest{Directory: dir, Entry: e, ExpectedExtended: expected}) + _, err := c.fc.UpdateEntry(ctx, &filerpb.UpdateEntryRequest{Directory: dir, Entry: e, ExpectedExtended: expected, Condition: cond}) if err == nil { return nil } diff --git a/seaweed-block/core/host/volume/status_chunk_test.go b/seaweed-block/core/host/volume/status_chunk_test.go index 69782bc4e3..cec62f8ba8 100644 --- a/seaweed-block/core/host/volume/status_chunk_test.go +++ b/seaweed-block/core/host/volume/status_chunk_test.go @@ -16,7 +16,7 @@ import ( // GET /status/chunk?volume= answers the served volume's space accounting // and retention policy; the usual chunk-route guards apply. func TestStatusServer_StatusChunkUsage(t *testing.T) { - fake := &fakeChunkControl{usage: chunkstore.Usage{Snapshots: 1, Dependents: 2, OwnChunks: 3, ForeignChunks: 4}} + fake := &fakeChunkControl{usage: chunkstore.Usage{Snapshots: 1, Dependents: 2, OwnChunks: 3, ForeignChunks: 4, MetadataGuard: chunkstore.MetadataGuardChunks}} s := chunkServer(t, fake, true) w := serveStatusChunk(t, s, http.MethodGet, "/status/chunk?volume=v1") if w.Code != http.StatusOK { diff --git a/seaweed-block/docs/design/invariants.md b/seaweed-block/docs/design/invariants.md index c0ddb4386a..b7dfe5d590 100644 --- a/seaweed-block/docs/design/invariants.md +++ b/seaweed-block/docs/design/invariants.md @@ -641,6 +641,8 @@ stateDiagram-v2 idle --> clean: BeginClean(c) clean --> idle: EndClean(c) snap --> snap: PublishList (durable session pages, base CAS) + idle --> idle: DeleteSnapshotWithIntent (adopted pages read again, one CAS) + snap --> snap: DeleteSnapshotWithIntent (adopted pages read again, one CAS) clean --> clean: AdvanceList (effects then cursor CAS) clean --> clean: roots, segments, chunk shards and unreached list pages (conditional removal) idle --> deleting: MarkDeleting (no holder, no dependents) @@ -655,7 +657,7 @@ stateDiagram-v2 | snap(s), list slot empty | snap(s), list cursor published | same full holder, open session and original base generation; every page durable; full slot returns queue_full without replacing work; unknown reply retains protection | `list_chain.go` `StageListPage`, `RunPublishList` | `INV-LIST-PUBLISH-001` | | clean(c), current list page | clean(c), next continuation or none | exact observed cursor CAS only after authenticated page effects succeed; failed reads and failed effects leave cursor unchanged | `list_chain.go` `RunAdvanceList` | `INV-LIST-CURSOR-001` | | clean(c), stored list page | clean(c), unreached page removed | tags before HEAD; current clean session; spare all current-chain pages; conditional mark then delete | `remove.go` `Cleaner.Page` | `INV-LIST-RETIRE-001` | -| idle/snap, retained snapshot | same activity, row removed and intent published | one CAS removes only captured name/gen and names its durable chain; each page present, this attempt's tag, unmarked; clean activity refuses | `delete_intent.go` `RunDeleteSnapshotWithIntent` | `INV-SNAPSHOT-DELETE-INTENT-001`, `INV-SNAPSHOT-DELETE-ADOPT-001` | +| idle/snap, retained snapshot | same activity, row removed and intent published | one CAS removes only captured name/gen and names its durable chain; each page present, this attempt's tag, unmarked, then read and authenticated again after adoption; clean activity refuses | `delete_intent.go` `RunDeleteSnapshotWithIntent` | `INV-SNAPSHOT-DELETE-INTENT-001`, `INV-SNAPSHOT-DELETE-ADOPT-001`, `INV-SNAPSHOT-DELETE-ADOPT-002` | | idle live/detached, persisted delete intent | idle live/detached, next intent page or none | receipt-independent continuation from current HEAD; live-root and conditional effect guards; cursor follows completed effects | `delete_intent.go` `RunConsumeSnapshotDeleteIntent`; `BCatalog.CleanSnapshotDeletePage`; `LayoutRemote.Clean` | `INV-SNAPSHOT-DELETE-CONSUME-001` | | idle | snap(s) | caller is the holder at HEAD's epoch (epoch, server and claim id); HEAD present; snap(s) again is a replay, any other activity is refused | head.go `Head.Begin`, `runTransition` | `INV-SNAPK-HEAD-WRITE-001`, `INV-SNAPK-BEGIN-001` | | snap(s) | idle | holder at HEAD's epoch (epoch, server and claim id); activity is snap(s); over idle it succeeds without a write and means only that no activity remains; before resuming a failed stop, abort its still-open session and re-read HEAD: only matching live/idle resumes, detached goes Down, absent/unknown stays stopped | head.go `Head.Abort`; durable/provider_layout.go `settleLayoutStop` | `INV-SNAPK-ABORT-001` | @@ -1095,6 +1097,7 @@ Notes: | `INV-WS-ONE-PROCESS-PER-HOST-001` | One host runs at most one live blockvolume per volume: each takes the volume's exclusive host lock before its store opens and holds it until the store closes; a second is refused before it opens anything, whatever its `--durable-root`. | M4 (start) → Attaching, Refused | `core/frontend/durable/provider.go` `DurableProvider.lockVolumeOnHost` | `TestOneLiveProcessPerVolumePerHost`, `TestHostVolumeLockDirectoryCreatedOrRefused`, `TestHostVolumeLockRefusesNonDirectoryLockPath`, `TestHostVolumeLockTakesReadOnlyLockFile` (`core/frontend/durable/one_process_per_volume_test.go`); `TestHostVolumeLockCreatesParent0755AndLocks0700`, `TestHostVolumeLockKeepsExistingDirectoryModes` (`core/frontend/durable/volume_lock_parent_mode_test.go`); `TestVolumeLockDirTestOnlyRefusedUnderSystemd` (`cmd/blockvolume/volume_lock_flag_test.go`) | — | ACTIVE | | `INV-CHUNK-LEASE-REQUIRED-001` | Blockvolume refuses walstore-chunk startup without --workspace-lease before any host or store is opened. The refusal names concurrent acknowledging writers and acknowledged-write loss after a forced move; plain walstore startup is unchanged. | M4 startup → Refused | `cmd/blockvolume/main.go` `parseFlags` | `TestChunkVolumeRequiresWorkspaceLeaseBeforeStart` | — | ACTIVE | | `INV-WS-CONDITIONAL-HEAD-001` | Catalog startup requires a wrong-generation conditional update of a disposable HEAD to be definitely refused and leave its bytes and generation unchanged. Unknown probe outcomes refuse admission; cleanup failures only warn with the leftover path. No volume HEAD is used. | M4 startup → Refused | `core/frontend/chunkstore/swfs_catalog.go` `DialBCatalog`; `startup_head_probe.go` `checkConditionalHead` | `TestCatalogStartupRequiresWrongGenerationHeadRefusal`, `TestConditionalHeadNextStartCleansCrashLeftovers`, `TestConditionalHeadSweepWaitsAndLeavesNewProbes`, `TestCatalogStartupDoesNotWaitForUndeletableProbe`, `TestLayoutIdentityWriterAndReaders` | — | ACTIVE | +| `INV-WS-CHUNK-CONDITION-PROBE-001` | Catalog startup turns the chunk guard on only if the filer definitely refuses a mismatched chunk-condition update of the disposable HEAD; any other answer leaves the page re-read as the only check. No version string is read; the startup log and /status/chunk name the guard. | M4 startup | `core/frontend/chunkstore/startup_head_probe.go` `probeChunkCondition`; `catalog_b.go` `Store`, `MetadataGuard`, `Usage` | `TestTheStartupProbeTurnsTheChunkGuardOnOnlyForAFilerThatEnforcesIt` (`core/frontend/chunkstore/startup_chunk_condition_probe_test.go`), `TestCatalogStartupRequiresWrongGenerationHeadRefusal` (`core/frontend/chunkstore/startup_head_probe_test.go`), `TestStatusServer_StatusChunkUsage` (`core/host/volume/status_chunk_test.go`) | MetaABA r2, checked outside the repository: guard on = `safe_chunks_equal`; the fallback is the re-read, which a chunk still queued for deletion defeats (`mut_reread_delayed`) | ACTIVE | | `INV-WS-SINGLE-FILER-001` | Startup requires all configured masters to answer and agree on a leader; only that leader listing exactly the target filer and confirming leadership afterward admits. Followers' lists do not decide. Unknown views retry within 60 s. This census does not fence later filer registration. | M4 (startup) → Refused | `core/frontend/chunkstore/single_filer.go` `CheckSingleFiler`; `cmd/blockvolume/chunk_remote.go` `newChunkWiring`; `cmd/sw-block/chunk.go` `refuseUnlessSingleFiler` | `TestSingleFilerCensusUsesTheAgreedLeader`; `TestCheckSingleFilerRefusesAnotherOrSeveralFilers`, `TestCheckSingleFilerFailsClosed`, `TestCheckSingleFilerNeedsEveryMasterToAnswer`, `TestIsTargetComparesScopedAddresses`, `TestCheckSingleFilerPasses` (`core/frontend/chunkstore/single_filer_test.go`), `TestChunkWiringRefusesAMultiFilerGroup` (`cmd/blockvolume/single_filer_test.go`), `TestOpsChunk_WritingCommandsRunTheSingleFilerCheck` (`cmd/sw-block/chunk_start_check_test.go`), `TestOpsChunk_VerifyRunsTheSingleFilerCheck` (`cmd/sw-block/chunk_verify_test.go`) | — | ACTIVE | | `INV-CLI-SINGLE-FILER-CLIENT-001` | Chunk metadata commands refuse missing, typed-nil and non-SWFS clients before catalog access; only a live SWFS client can run the census. | M4 startup client admission | `cmd/sw-block/chunk.go` `checkSingleFiler`, `refuseUnlessSingleFiler` | `TestSingleFilerCheckRefusesUnsupportedClients`, `TestOpsChunkWritingRefusesUnsupportedFilerBeforeCatalogAccess` | — (client capability guard) | ACTIVE | | `INV-WS-LEASE-REGRANT-001` | Re-grant after expiry keeps the same holder and epoch, with no pending move or revocation, a certain store, and one durable write after the horizon/deadline plus skew barrier. Restart begins a new session and voids the old; ordinary reopen keeps HEAD identity (epoch, holder, claim) unchanged. | M2 Expired → Granted; M9 Start | `core/authority/workspace_lease_view.go` `regrantWorkspaceLease`; `core/authority/workspace.go` `forcedMoveBarrierLocked`; `core/frontend/chunkstore/layout/start.go` `Start` | `TestWorkspaceLeaseExpiredSameHolderRegrantIsDurable`, `TestWorkspaceLeaseRegrantWaitsForFullSkew`, `TestWorkspaceLeaseRegrantDefeatsAlreadyPassedForcedPreflight`, `TestWorkspaceLeaseForcedIssueDefeatsOldHolderRegrant`, `TestWorkspaceLeaseRegrantWaitsForDurabilityAndLatchesFailure` (`core/authority/workspace_regrant_test.go`); `TestWorkspaceLeaseRegrantPreservesLocalLogThroughFirstCut` (`core/authority/workspace_regrant_storage_test.go`); `TestStart_OwnEpochFreshRootRefusedBeforeClaim`, `TestStart_OwnEpochSameRootContinues` (`core/frontend/chunkstore/layout/start_test.go`); `TestClaim_WritesItsClaimID`, `TestRunClaim_VoidsTheOldSession` (`core/frontend/chunkstore/layout/claim_test.go`); `TestLocalReopenClaimsBeforeServing` (`core/frontend/durable/provider_reopen_belt_test.go`) | `WorkspaceRegrant` `NoDualServingInc`, `RegrantNoLoss`, `DiskCoversMemory`; `INV-SNAPK-START-ROOT-001` | ACTIVE | @@ -1547,6 +1550,8 @@ Notes: | `INV-SNAPSHOT-DELETE-INTENT-001` | Removing a captured snapshot incarnation and publishing its durable intent are one HEAD CAS; an unrelated metadata retry keeps the same target and durable pages. | M9 metadata delete | `delete_intent.go` `RunDeleteSnapshotWithIntent` | `TestDeleteSnapshotWithIntent_Closure`, `TestRunDeleteSnapshotWithIntent_InterruptAtEveryStep`, `TestDeleteIntentRetryKeepsDurablePagesAcrossMetadataCAS` | SnapDelete 241-245; PageChain 246-249 | DORMANT | | `INV-SNAPSHOT-DELETE-CONSUME-001` | Only current persisted delete intent authorizes offline reclamation; live roots remain protected, failed effects retain the cursor, and receipt retirement cannot erase work. | M9 idle intent continuation | `core/frontend/chunkstore/layout/delete_intent.go` `RunConsumeSnapshotDeleteIntent`; `core/frontend/chunkstore/layout/remove.go` `Cleaner.removePlanned`; `core/frontend/chunkstore/layout_remote.go` `LayoutRemote.Clean` | `TestConsumeSnapshotDeleteIntent_Closure`, `TestDeleteIntentOfflineAndReplacementPreserved`, `TestDeleteIntentMarkConflictKeepsUnfinishedPage`, `TestLayoutSnapshotDeleteIntentResumesWithoutReceipt`, `TestCatalogDeleteIntentResumesOnePageWithoutNamespaceScan`, `TestCatalogIntentCursorInterruptAndLostReply`, `TestHolderMaintenanceResumesThePersistedDeleteIntent`, `TestHolderMaintenanceIntentIsCancelledBeforeTheCutJoins` | PageChain r2 246,251-253 (az1 13/13); StaleClean 159-161 | ACTIVE | | `INV-SNAPSHOT-DELETE-ADOPT-001` | Publication adopts every intent page with a fresh CAS-base tag and checks it is present, this attempt's and unmarked; stale cleaners/adopters cannot remove or retag a published page, and staging never restores old tags. | M9 delete intent publication | `delete_intent.go` `adoptDeleteIntentPage`, `RunDeleteSnapshotWithIntent`, `StageSnapshotDeletePage` | `TestDeleteIntentRefreshedBaseFencesDelayedCleanerMark`, `TestDeleteIntentRefreshedBaseFencesDelayedCleanerDelete`, `TestDeleteIntentAdoptionCannotRestoreStaleTags`, `TestDeleteIntentStagingNeverRevertsPublishedTags`, `TestDeleteIntentPublicationChecksAdoptedPageMetadata`, `TestGenericIntentStagingCannotUndoRefreshedPublication` | StaleClean 159-161; exact-head refinement read required | DORMANT | +| `INV-SNAPSHOT-DELETE-ADOPT-002` | After adopting an intent page under its own tag, publication reads the page again and authenticates it; a page that no longer reads or holds other bytes refuses the publication. The filer frees chunks from a deletion queue, so a reference whose chunk is still queued reads intact and publishes. | M9 delete intent publication | `delete_intent.go` `RunDeleteSnapshotWithIntent`, `readListPage` | `TestASnapshotDeleteIsNotPublishedOverAPageWhoseDataWasFreed` (`core/frontend/chunkstore/layout/delete_intent_reread_test.go`); store witness `TestWithoutTheChunkGuardAStaleMetadataChangeOverwritesARecreatedObject` (`core/frontend/chunkstore/layout_change_meta_recreated_test.go`) | MetaABA r2, checked outside the repository: the re-read alone does not hold `PublishedReadable` once the filer frees chunks later from a queue (`mut_reread_delayed`); with the chunk guard it holds (`safe_chunks_equal`). r1's `safe_reread_only` held only for immediate frees (historical scope) | ACTIVE | +| `INV-LAYOUT-META-CHUNKS-001` | With the chunk guard on, an adoption or mark writes its looked-up entry back only while the entry's chunk fids are unchanged, so it cannot land on an object deleted and created again since its lookup; a cleaner's delete expects its own mark, so it follows. | M9 delete intent publication | `core/frontend/chunkstore/layout_store.go` `changeMeta`; `swfs.go` `UpdateEntryIfChunks` | `TestAStaleMetadataChangeDoesNotOverwriteARecreatedObject`, `TestAStaleCleanerMarkDoesNotDeleteARecreatedObject`, `TestWithTheChunkGuardAnUnchangedObjectIsStillAdoptedMarkedAndDeleted` (`core/frontend/chunkstore/layout_change_meta_recreated_test.go`) | MetaABA r2, checked outside the repository: `PublishedReadable` (`safe_chunks_equal`, `safe_legacy_chunks_equal`) | ACTIVE | The snapshot-delete consumer and list-page retirement above are reachable through holder maintenance and covered by Go assertions. Their ACTIVE status describes that reachability and test coverage, not fresh Linux, composed-operation or release qualification. Cut and upload-intent producers remain deferred; their dormant publication rows are not activated by this consumer slice. diff --git a/seaweed-block/docs/status-schema.md b/seaweed-block/docs/status-schema.md index c39a41b0fb..68624489d6 100644 --- a/seaweed-block/docs/status-schema.md +++ b/seaweed-block/docs/status-schema.md @@ -468,6 +468,7 @@ Chunk store usage of a walstore-chunk volume (only with --chunk-control-endpoint | `dependents` | int | — | | `own_chunks` | int | — | | `foreign_chunks` | int | — | +| `metadata_guard` | string | MetadataGuard names the protection of the volume's metadata changes: filer_chunk_condition (the startup probe saw the filer enforce the chunk condition) or page_reread_only (enforcement was not established at startup; delete intent pages are re-read). | ### `GET /status/nvme`