From 4eb8b2a2fac2877e73b48e3cd00af8b717186dcd Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 4 Dec 2026 21:26:22 -0800 Subject: [PATCH] seaweed-block: blockmaster answers an unreadable store record with FailedPrecondition GetReplicaStore answered an invalid recorded store id with Unavailable, a transport code. The holder now waits in-process on Unavailable, so a corrupt record left the unit active and waiting forever instead of exiting 75 store_record_unreadable. FailedPrecondition is an answer: the holder refuses at once, as INV-WALSTORE-NO-EMPTY-STORE-001 states, and the process test covers that exit again. Co-Authored-By: Claude Opus 5.5 --- .../cmd/blockvolume/lost_store_exit_test.go | 24 +++++++++++-------- .../host/master/get_replica_store_test.go | 4 ++-- .../core/host/master/store_attestation.go | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/seaweed-block/cmd/blockvolume/lost_store_exit_test.go b/seaweed-block/cmd/blockvolume/lost_store_exit_test.go index 1c7e2b6a60..d67ad57694 100644 --- a/seaweed-block/cmd/blockvolume/lost_store_exit_test.go +++ b/seaweed-block/cmd/blockvolume/lost_store_exit_test.go @@ -26,7 +26,7 @@ import ( type storeRecordMaster struct { control.UnimplementedLifecycleServiceServer mu sync.Mutex - mode string // "creating", "ended", "older", "unavailable" + mode string // "creating", "ended", "older", "unreadable", "unavailable" } func (m *storeRecordMaster) set(mode string) { m.mu.Lock(); m.mode = mode; m.mu.Unlock() } @@ -43,6 +43,8 @@ func (m *storeRecordMaster) GetReplicaStore(_ context.Context, q *control.GetRep return &control.GetReplicaStoreResponse{Listed: true, CreationEnded: true}, nil case "older": return nil, status.Error(codes.Unimplemented, "unknown method GetReplicaStore") + case "unreadable": + return nil, status.Error(codes.FailedPrecondition, "the replica's store record is unreadable") } return nil, status.Error(codes.Unavailable, "lifecycle store unavailable") } @@ -102,11 +104,11 @@ func runHolder(t *testing.T, bin, master, root, locks string, until func() bool, // before it creates or writes anything. Composed on the real binary: while // the volume is creating an empty state directory creates the store; once // creation ended, a store other than the recorded one, and a wiped state -// directory, exit 78 store_lost; an older master (no GetReplicaStore) exits -// 75 with an empty state directory left empty. A master that gives no reply -// is waited out inside the process, writing nothing, so a start during an -// outage does not burn the unit's start limit; once it answers creating, the -// same process creates its store. +// directory, exit 78 store_lost; an older master (no GetReplicaStore) and an +// unreadable record exit 75 with an empty state directory left empty. A +// master that gives no reply is waited out inside the process, writing +// nothing, so a start during an outage does not burn the unit's start limit; +// once it answers creating, the same process creates its store. func TestBlockvolumeAsksTheMasterBeforeCreatingItsStore(t *testing.T) { if testing.Short() { t.Skip("builds and runs the blockvolume binary") @@ -188,11 +190,13 @@ func TestBlockvolumeAsksTheMasterBeforeCreatingItsStore(t *testing.T) { } empty(t) - m.set("older") - if code, _, out := runHolder(t, bin, ln.Addr().String(), root, locks, nil, 60*time.Second); code != exitWorkspaceRetry || !strings.Contains(out, "master_too_old") { - t.Fatalf("older master, empty state: exit %d, want 75 master_too_old\n%s", code, out) + for mode, reason := range map[string]string{"older": "master_too_old", "unreadable": "store_record_unreadable"} { + m.set(mode) + if code, _, out := runHolder(t, bin, ln.Addr().String(), root, locks, nil, 60*time.Second); code != exitWorkspaceRetry || !strings.Contains(out, reason) { + t.Fatalf("%s master, empty state: exit %d, want 75 %s\n%s", mode, code, reason, out) + } + empty(t) } - empty(t) // No reply for longer than the old 10 s read bound plus the unit's 5 s // restart delay: the process stays, writes nothing, and creates its diff --git a/seaweed-block/core/host/master/get_replica_store_test.go b/seaweed-block/core/host/master/get_replica_store_test.go index 0abe2428b8..9b6af02e2a 100644 --- a/seaweed-block/core/host/master/get_replica_store_test.go +++ b/seaweed-block/core/host/master/get_replica_store_test.go @@ -68,8 +68,8 @@ func TestGetReplicaStoreAnswersFromTheMastersCreationFact(t *testing.T) { } for _, bad := range []string{"zz", "00000000000000000000000000000000"} { seed(&attestedStores{Stores: map[string]string{"r1": bad}}) - if r, err := ask("vol"); status.Code(err) != codes.Unavailable { - t.Fatalf("an invalid recorded id %q: %+v %v, want Unavailable (never creating)", bad, r, err) + if r, err := ask("vol"); status.Code(err) != codes.FailedPrecondition { + t.Fatalf("an invalid recorded id %q: %+v %v, want FailedPrecondition (an answer, never creating)", bad, r, err) } } } diff --git a/seaweed-block/core/host/master/store_attestation.go b/seaweed-block/core/host/master/store_attestation.go index 73cc199f09..dba096ac2d 100644 --- a/seaweed-block/core/host/master/store_attestation.go +++ b/seaweed-block/core/host/master/store_attestation.go @@ -609,7 +609,7 @@ func (s *services) GetReplicaStore(ctx context.Context, q *control.GetReplicaSto state, id := s.host.ReplicaStoreState(q.GetVolumeId(), q.GetReplicaId()) switch state { case replicaStoreUnknown: - return nil, status.Error(codes.Unavailable, "the replica's store record is unreadable (an invalid recorded store id)") + return nil, status.Error(codes.FailedPrecondition, "the replica's store record is unreadable (an invalid recorded store id)") case replicaStoreEnded: out.CreationEnded = true if !id.IsZero() {