master: keep a quarantined copy out of the writables when its server marks it writable

A volume server that makes a volume writable, as a vacuum does after its
commit, tells the master straight away through VolumeMarkReadonly with
IsReadonly unset. The master applied that to the layout directly, so a
quarantined copy returned to the writable list until its next heartbeat
put the quarantine back, and file ids could be assigned on it meanwhile.

Record the server's flag but keep the layout mark while the copy is
quarantined; the heartbeat that repeats the flag pushes the mark again.
This commit is contained in:
Chris Lu committed 2026-12-06 00:41:02 -08:00
1 parent 0aea318693
commit b083f40cfd
3 files changed
+39 -1

No files matched your search

+1 -1
View File
@@ -532,7 +532,7 @@ func (ms *MasterServer) VolumeMarkReadonly(ctx context.Context, req *master_pb.V
glog.V(0).Infof("volume %d marked readonly with %d pending bytes", vid, pending)
}
} else {
vl.SetVolumeWritable(dn, vid)
ms.Topo.SetVolumeWritable(vl, dn, vid)
}
}
}
+24
View File
@@ -762,3 +762,27 @@ func TestEcStaleShardsReleaseKeepsEncodeFreeze(t *testing.T) {
require.False(t, isWritable(t, topo, v), "the release must not reopen a source an encode froze")
requireOnlyMarked(t, recorder.to(dn1))
}
func TestQuarantineSurvivesServerMarkingItWritable(t *testing.T) {
topo := NewTopology("topo", nil, 128, 3, false)
dn1, dn2 := NewDataNode("server1"), NewDataNode("server2")
rp, _ := super_block.NewReplicaPlacementFromString("000")
v := storage.VolumeInfo{Id: 7, Collection: "a", ReplicaPlacement: rp, Ttl: needle.EMPTY_TTL, Version: needle.Version3}
reportVolume(topo, dn1, false)
mountEcShards(topo, dn2, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
topo.duplicateFlagChecks.Wait()
require.True(t, topo.isQuarantined(dn1, v.Id))
// a vacuum's commit ends with the server telling the master the copy is
// writable again, ahead of its next heartbeat
vl := topo.FindVolumeLayout(v.Collection, v.ReplicaPlacement, v.Ttl, types.ToDiskType(v.DiskType))
topo.SetVolumeWritable(vl, dn1, v.Id)
require.False(t, isWritable(t, topo, v), "the server's word must not lift the quarantine")
// without a quarantine the same call reopens the copy
deleteEcShards(topo, dn2, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)
reportVolume(topo, dn1, true)
topo.SetVolumeWritable(vl, dn1, v.Id)
require.True(t, isWritable(t, topo, v))
}
+14
View File
@@ -368,6 +368,20 @@ func (t *Topology) enforceQuarantine(dn *DataNode, vi storage.VolumeInfo) storag
return vi
}
// SetVolumeWritable applies a volume server's own word that its copy of vid
// takes writes again, as a vacuum sends after its commit. A quarantined copy
// keeps its layout mark; the heartbeat that repeats the flag marks the server
// again.
func (t *Topology) SetVolumeWritable(vl *VolumeLayout, dn *DataNode, vid needle.VolumeId) {
t.quarantineLock.Lock()
defer t.quarantineLock.Unlock()
if t.isQuarantined(dn, vid) {
dn.SetVolumeReadOnly(vid, false)
return
}
vl.SetVolumeWritable(dn, vid)
}
func NewTopology(id string, seq sequence.Sequencer, volumeSizeLimit uint64, pulse int, replicationAsMin bool) *Topology {
t := &Topology{}
t.id = NodeId(id)