mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
volume: the replica-store wait applies only where stores are required
A host whose replication slot does not count peers by recorded store counts no peer ack, so the creation wait does not close its frontend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
58b3c02386
commit
0634cce906
2 files changed
+28
-2
No files matched your search
@@ -16,8 +16,17 @@ import (
|
||||
// projection is not Healthy, writes through the real backend refuse, and
|
||||
// status says "creating: waiting for replica attestations (n of N)". The
|
||||
// same-generation re-send with nothing awaited opens it.
|
||||
// requiringReplication is a replication slot that counts peers only with
|
||||
// recorded stores (as replication.ReplicationVolume does on a volume host).
|
||||
type requiringReplication struct{ *stubReplication }
|
||||
|
||||
func (requiringReplication) RequireAttestedStores() {}
|
||||
|
||||
func TestNewVolumePrimaryServesNothingBeforeReplicaAttestations(t *testing.T) {
|
||||
h, _, _ := newStubbedHost(t, "vol1", "rB", &orderingRecorder{})
|
||||
h, _, rep := newStubbedHost(t, "vol1", "rB", &orderingRecorder{})
|
||||
h.replicationMu.Lock()
|
||||
h.setReplicationLocked(requiringReplication{rep})
|
||||
h.replicationMu.Unlock()
|
||||
proj := &mutableProjector{p: engine.ReplicaProjection{Mode: engine.ModeHealthy, Epoch: 2, EndpointVersion: 1}}
|
||||
h.view = NewAdapterProjectionView(proj, "vol1", "rB", h)
|
||||
if err := h.SetSelfFence(&switchFencer{}); err != nil {
|
||||
@@ -52,3 +61,16 @@ func TestNewVolumePrimaryServesNothingBeforeReplicaAttestations(t *testing.T) {
|
||||
t.Fatalf("write once nothing is awaited: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// A host whose replication slot does not require recorded stores counts no
|
||||
// peer ack by store, so the wait does not apply to it: the fact's count
|
||||
// does not close its frontend.
|
||||
func TestReplicaStoresWaitOnlyWhereStoresAreRequired(t *testing.T) {
|
||||
h, _, _ := newStubbedHost(t, "vol1", "rB", &orderingRecorder{})
|
||||
fact := selfFact(2)
|
||||
fact.ReplicaStoresAwaited, fact.ReplicaStoresInitial = 2, 2
|
||||
h.noteReplicaStores(fact)
|
||||
if reason := h.ReplicaStoresAwaited(); reason != "" {
|
||||
t.Fatalf("a host without a store-requiring slot waits: %q", reason)
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,12 @@ func (h *Host) noteReplicaStores(f *control.AssignmentFact) {
|
||||
|
||||
// ReplicaStoresAwaited is the reason a new volume's primary serves nothing
|
||||
// yet: "" once every initial replica's store is recorded (or the volume
|
||||
// never waited).
|
||||
// never waited). It applies where the replication slot counts peers only
|
||||
// with recorded stores; a host without one counts no peer ack at all.
|
||||
func (h *Host) ReplicaStoresAwaited() string {
|
||||
if _, ok := h.getReplication().(storeRequirer); !ok {
|
||||
return ""
|
||||
}
|
||||
v := h.storesAwaited.Load()
|
||||
waiting, initial := v>>32, v&0xffffffff
|
||||
if waiting == 0 {
|
||||
|
||||
Reference in new issue
Block a user