mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
799c5c1130
commit
4eb8b2a2fa
3 files changed
+17
-13
No files matched your search
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user