mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
storage: no upgrade pass on a store this start created
A new volume's store (an empty HEAD, every chunk local and zero) is unknown only because its upgrade had no seed; the first cut takes its chunks as candidates. The procedures' first snapshots were refused in_progress by that pass. A restart before the first cut runs it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ecc3a1fd05
commit
858720738c
2 files changed
+40
-20
No files matched your search
@@ -286,25 +286,40 @@ func TestAV11AttachRefusesARemoteThatDeclinesTheHeadFormat(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
// A store this start created (a new volume: an empty HEAD, every chunk local
|
||||
// and zero) upgraded at level 1 with no clean-stop proof runs no compare pass
|
||||
// and holds no cut, so the first cut (a snapshot right after a new volume
|
||||
// starts) is not refused in_progress. A fresh-from-HEAD store whose chunks
|
||||
// are absent runs none either (nothing unknown).
|
||||
func TestAFreshStoreAtLevelOneRunsNoUpgradePass(t *testing.T) {
|
||||
withV11Format(t)
|
||||
withoutPassWait(t)
|
||||
s, l, _ := lazyFreshVolume(t)
|
||||
l.stMu.Lock()
|
||||
pass := l.pass
|
||||
l.stMu.Unlock()
|
||||
if pass != nil {
|
||||
t.Fatalf("a fresh store started an upgrade pass (status %+v); want none: nothing unknown to compare", l.Stats().UpgradePass)
|
||||
}
|
||||
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)
|
||||
for _, tc := range []string{"created this start, empty HEAD", "fresh from HEAD, chunks absent"} {
|
||||
t.Run(tc, func(t *testing.T) {
|
||||
withV11Format(t)
|
||||
withoutPassWait(t)
|
||||
var s *WALStore
|
||||
var l *chunkLayerImpl
|
||||
if tc == "created this start, empty HEAD" {
|
||||
s, _ = newChunkTestStore(t)
|
||||
cfg := ctConfig(2)
|
||||
cfg.Bitmap = nil
|
||||
cfg.FreshFromHead, cfg.CreatedThisStart = true, true
|
||||
l = mustAttach(t, s, newFakeChunkRemote(), cfg).(*chunkLayerImpl)
|
||||
} else {
|
||||
s, l, _ = lazyFreshVolume(t)
|
||||
}
|
||||
l.stMu.Lock()
|
||||
pass := l.pass
|
||||
l.stMu.Unlock()
|
||||
if pass != nil {
|
||||
t.Fatalf("%s: an upgrade pass started (status %+v); want none", tc, l.Stats().UpgradePass)
|
||||
}
|
||||
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("%s: the first cut at level 1: %v, want it to run", tc, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -63,8 +63,13 @@ func (l *chunkLayerImpl) prepareUpgradePass(upgradedNow bool) error {
|
||||
// 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.
|
||||
// A store this start created has never held data: its chunks are all
|
||||
// zero, known to need no compare (unknown only because the upgrade had no
|
||||
// seed); the first cut takes them as candidates. A restart before that
|
||||
// cut is not created this start and runs the pass.
|
||||
_, anyU := sh.firstUnknown()
|
||||
if (!anyU && !sh.rebuilt) || (os.IsNotExist(statErr) && !upgradedNow && !sh.rebuilt) {
|
||||
createdNow := upgradedNow && l.cfg.CreatedThisStart
|
||||
if (!anyU && !sh.rebuilt) || (createdNow && !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