mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
storage, master: no pass on a fresh store; old heartbeats accepted (r2.881)
A v1.1 store with no unknown chunk and no rebuilt page starts no upgrade compare pass and holds no cut, cursor or not: a fresh volume's chunks are absent, so a new cluster's first snapshot runs at once (the process-level procedures were refused in_progress). A heartbeat is accepted and its read level recorded whatever it reads; an old binary is refused at the grant. Test fakes that stand for v1.1 hosts in other packages report reads_level 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1618411850
commit
2ac97a00a5
10 files changed
+54
-27
No files matched your search
@@ -133,7 +133,7 @@ func reportImportedVolume(t *testing.T, o control.ObservationServiceClient) {
|
||||
t.Helper()
|
||||
ctx, c := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer c()
|
||||
_, e := o.ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "s2", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, Slots: []*control.HeartbeatSlot{{VolumeId: "v1", ReplicaId: "r2", DataAddr: "10.0.0.2:19080", CtrlAddr: "10.0.0.2:19081"}}})
|
||||
_, e := o.ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "s2", SentAt: timestamppb.Now(), Reachable: true, Eligible: true, Slots: []*control.HeartbeatSlot{{VolumeId: "v1", ReplicaId: "r2", DataAddr: "10.0.0.2:19080", CtrlAddr: "10.0.0.2:19081"}}})
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestProcedureTLSWrongNodeCertificateIsRefused(t *testing.T) {
|
||||
wantCode(t, "s2's certificate renewing s1's lease", err, codes.PermissionDenied)
|
||||
_, err = ws.AckWorkspaceRevoked(ctx, &control.WorkspaceRevocationAck{Identity: id, HeadGen: 1})
|
||||
wantCode(t, "s2's certificate ACKing for s1", err, codes.PermissionDenied)
|
||||
_, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "s1"})
|
||||
_, err = control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "s1"})
|
||||
wantCode(t, "s2's certificate heartbeating as s1", err, codes.PermissionDenied)
|
||||
stream, err := control.NewAssignmentServiceClient(conn).SubscribeAssignments(ctx, &control.SubscribeRequest{VolumeId: "v1", ReplicaId: "r1", ServerId: "s1"})
|
||||
if err == nil {
|
||||
|
||||
@@ -37,7 +37,7 @@ func TestOpsChunkVolumeDeleteRefusalSaysNothingWasPersisted(t *testing.T) {
|
||||
defer cancel()
|
||||
// The primary's attestation of its stores ends creation, as its heartbeat
|
||||
// carries it in production.
|
||||
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
Slots: []*control.HeartbeatSlot{{VolumeId: "vol-f", ReplicaId: "r1", DataAddr: "127.0.0.1:19200", CtrlAddr: "127.0.0.1:19100"}},
|
||||
StoreAttestation: &control.StoreAttestation{VolumeId: "vol-f", ReplicaId: "r1", Epoch: 1, Stores: []*control.AttestedStore{{ReplicaId: "r1", StoreId: bytes.Repeat([]byte{7}, 16)}}}}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -92,7 +92,7 @@ func attestStores(t *testing.T, h *master.Host) {
|
||||
defer conn.Close()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
Slots: []*control.HeartbeatSlot{{VolumeId: "vol-f", ReplicaId: "r1", DataAddr: "127.0.0.1:19200", CtrlAddr: "127.0.0.1:19100"}},
|
||||
StoreAttestation: &control.StoreAttestation{VolumeId: "vol-f", ReplicaId: "r1", Epoch: 1, Stores: []*control.AttestedStore{{ReplicaId: "r1", StoreId: bytes.Repeat([]byte{7}, 16)}}}}); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -53,7 +53,7 @@ func seedForcedVolumeLease(t *testing.T, h *master.Host, renew bool) {
|
||||
if _, err := ws.PlaceWorkspace(ctx, &control.WorkspacePlacement{VolumeId: "vol-f", ServerId: "node-a", ReplicaId: "r1"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
if _, err := control.NewObservationServiceClient(conn).ReportHeartbeat(ctx, &control.HeartbeatReport{ReadsLevel: 1, ServerId: "node-a", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
Slots: []*control.HeartbeatSlot{{VolumeId: "vol-f", ReplicaId: "r1", DataAddr: "127.0.0.1:19200", CtrlAddr: "127.0.0.1:19100"}}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func attestStores(t *testing.T, addr string, epoch uint64) {
|
||||
store := func(b byte) []byte { id := make([]byte, 16); id[15] = b; return id }
|
||||
att := &control.StoreAttestation{VolumeId: "v1", ReplicaId: "r1", Epoch: epoch, Stores: []*control.AttestedStore{
|
||||
{ReplicaId: "r1", StoreId: store(1)}, {ReplicaId: "r2", StoreId: store(2)}}}
|
||||
if _, err := control.NewObservationServiceClient(c).ReportHeartbeat(context.Background(), &control.HeartbeatReport{
|
||||
if _, err := control.NewObservationServiceClient(c).ReportHeartbeat(context.Background(), &control.HeartbeatReport{ReadsLevel: 1,
|
||||
ServerId: "s1", SentAt: timestamppb.Now(), Reachable: true, Eligible: true,
|
||||
Slots: []*control.HeartbeatSlot{{VolumeId: "v1", ReplicaId: "r1", DataAddr: "127.0.0.1:19101", CtrlAddr: "127.0.0.1:19102"}},
|
||||
StoreAttestation: att}); err != nil {
|
||||
|
||||
@@ -46,18 +46,22 @@ func binaryTooOld(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// At level 0 every binary's heartbeat is taken; at level 1 one that reads
|
||||
// only level 0 (or reports nothing: a v1.0.x binary) is refused, typed
|
||||
// binary_too_old, and one that reads level 1 is taken (FormatGate: Join,
|
||||
// Eligible).
|
||||
func TestFormatGateRefusesAnOldBinarysHeartbeatAtLevel1(t *testing.T) {
|
||||
// Every binary's heartbeat is taken and its read level recorded, at level 0
|
||||
// and at level 1 alike (r2.881: the refusal is at the grant, never at the
|
||||
// heartbeat); at level 1 a host whose process reads only level 0 is then
|
||||
// known old, so placement skips it (its grant is refused at the publication
|
||||
// boundary: TestThePublicationBoundaryRefusesAnAskForAnOldServer).
|
||||
func TestFormatGateRecordsAnOldBinarysHeartbeatAtLevel1(t *testing.T) {
|
||||
r := newIsolationRig(t, false, upgradedStoreDir(t), t.TempDir())
|
||||
if err := r.fgHeartbeat("node-a", 0); err != nil {
|
||||
t.Fatalf("level 0: an old binary's heartbeat was refused: %v", err)
|
||||
}
|
||||
r.m.format.v.Store(1)
|
||||
if err := r.fgHeartbeat("node-a", 0); !binaryTooOld(err) || !strings.Contains(status.Convert(err).Message(), "reads format level 0") {
|
||||
t.Fatalf("level 1: an old binary's heartbeat: %v, want FailedPrecondition with reason %s", err, lifecycleclient.ReasonBinaryTooOld)
|
||||
if err := r.fgHeartbeat("node-a", 0); err != nil {
|
||||
t.Fatalf("level 1: an old binary's heartbeat was refused: %v, want accepted and recorded", err)
|
||||
}
|
||||
if why := r.m.placementTooOld("node-a"); !strings.Contains(why, "binary_too_old") {
|
||||
t.Fatalf("level 1: node-a after its level-0 report: placement %q, want known old", why)
|
||||
}
|
||||
if err := r.fgHeartbeat("node-b", 1); err != nil {
|
||||
t.Fatalf("level 1: a binary that reads level 1 was refused: %v", err)
|
||||
@@ -340,8 +344,11 @@ func TestAServerReadsTheLowestLevelOfItsProcesses(t *testing.T) {
|
||||
if err := r.fgProcessHeartbeat("node-b", "new-proc", "vb", 1); err != nil {
|
||||
t.Fatalf("level 1: the new process's own heartbeat was refused: %v", err)
|
||||
}
|
||||
if err := r.fgProcessHeartbeat("node-b", "old-proc", "va", 0); !binaryTooOld(err) {
|
||||
t.Fatalf("level 1: the old process's heartbeat: %v", err)
|
||||
if err := r.fgProcessHeartbeat("node-b", "old-proc", "va", 0); err != nil {
|
||||
t.Fatalf("level 1: the old process's heartbeat was refused: %v, want accepted and recorded", err)
|
||||
}
|
||||
if r.m.placementTooOld("node-b") == "" {
|
||||
t.Fatal("level 1: node-b is placeable while its old process is live")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -537,15 +537,12 @@ func (s *services) ReportHeartbeat(ctx context.Context, r *control.HeartbeatRepo
|
||||
if err := s.host.refuseServerIDFromOtherHost(r); err != nil {
|
||||
return nil, status.Error(codes.FailedPrecondition, err.Error())
|
||||
}
|
||||
// The format gate: the reporting process's read level, recorded before
|
||||
// it is judged (its server then reads at most that level for new work);
|
||||
// a process whose binary cannot read the cluster's format level is
|
||||
// refused, so it is never observed as a candidate.
|
||||
// The format gate: the reporting process's read level is recorded and
|
||||
// the heartbeat accepted whatever it reads (r2.881). An old binary is
|
||||
// refused where it matters: placement skips a host known to read a
|
||||
// lower level, and the grant (publication) refuses a holder process
|
||||
// whose own report is below the cluster's level, typed binary_too_old.
|
||||
s.host.reads.noteHeartbeat(r.GetServerId(), r.GetSlots(), r.GetReadsLevel())
|
||||
if level := s.host.formatLevel(); r.GetReadsLevel() < level {
|
||||
why := fmt.Sprintf("node %q process reads format level %d; the cluster's format level is %d (binary_too_old)", r.GetServerId(), r.GetReadsLevel(), level)
|
||||
return nil, lifecycleclient.WithReason(status.New(codes.FailedPrecondition, "heartbeat refused: "+why), lifecycleclient.ReasonBinaryTooOld).Err()
|
||||
}
|
||||
msg := heartbeatFromWire(r)
|
||||
if err := s.host.ingestHeartbeatRecordingHealth(msg); err != nil {
|
||||
return nil, fmt.Errorf("ingest: %w", err)
|
||||
|
||||
@@ -285,3 +285,23 @@ func TestAV11AttachRefusesARemoteThatDeclinesTheHeadFormat(t *testing.T) {
|
||||
t.Fatalf("level 1 over a capable remote: %v; want upgraded", err)
|
||||
}
|
||||
}
|
||||
|
||||
// A fresh store (every chunk absent, nothing local to compare) upgraded at
|
||||
// level 1 with no clean-stop proof runs no compare pass and holds no cut:
|
||||
// its chunks are absent, not unknown, so the first cut (a snapshot right
|
||||
// after a new volume starts) is not refused in_progress.
|
||||
func TestAFreshStoreAtLevelOneRunsNoUpgradePass(t *testing.T) {
|
||||
withV11Format(t)
|
||||
withoutPassWait(t)
|
||||
s, l, _ := lazyFreshVolume(t)
|
||||
if st := l.Stats().UpgradePass; st.State == "running" {
|
||||
t.Fatalf("a fresh store's upgrade pass: %+v, want none (nothing unknown to compare)", st)
|
||||
}
|
||||
if _, err := s.Write(1, makeBlock(ctBlockSize, 0xF1)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var refusal *ErrUpgradePassInProgress
|
||||
if _, err := l.Cut(ctTimeout(t)); errors.As(err, &refusal) || err != nil {
|
||||
t.Fatalf("the first cut of a fresh store at level 1: %v, want it to run", err)
|
||||
}
|
||||
}
|
||||
@@ -57,11 +57,14 @@ func (l *chunkLayerImpl) prepareUpgradePass(upgradedNow bool) error {
|
||||
if statErr != nil && !os.IsNotExist(statErr) {
|
||||
return statErr
|
||||
}
|
||||
// No cursor: a pass starts only after an unseeded upgrade by this attach
|
||||
// (its chunks are unknown) or when a page was rebuilt at open. Chunks
|
||||
// unknown only because they were written are dirty: cuts take them.
|
||||
// No unknown chunk and no rebuilt page: nothing to compare, so no pass and
|
||||
// no hold on cuts, cursor or not (a fresh or empty store's chunks are
|
||||
// absent, not unknown). No cursor: a pass starts only after an unseeded
|
||||
// upgrade by this attach (its chunks are unknown) or when a page was
|
||||
// rebuilt at open. Chunks unknown only because they were written are
|
||||
// dirty: cuts take them.
|
||||
_, anyU := sh.firstUnknown()
|
||||
if os.IsNotExist(statErr) && !(upgradedNow && anyU) && !sh.rebuilt {
|
||||
if (!anyU && !sh.rebuilt) || (os.IsNotExist(statErr) && !upgradedNow && !sh.rebuilt) {
|
||||
state := "none"
|
||||
if upgradedNow && l.cfg.CleanStop != nil {
|
||||
state = "seeded"
|
||||
|
||||
Reference in new issue
Block a user