mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 10:07:28 +01:00
fix: preserve staged candidate counts at the capture barrier
This commit is contained in:
1 parent
6c0661dc3e
commit
7003168a80
2 files changed
+25
-7
No files matched your search
@@ -91,13 +91,11 @@ func TestCopyErrorKeepsCapturedEqualMarks(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wantCompared, wantCandidates := int64(2), 0
|
||||
wantCompared := int64(2)
|
||||
if mode == "write_after_capture" {
|
||||
wantCompared++
|
||||
}
|
||||
if want == 5 {
|
||||
wantCandidates = 1
|
||||
}
|
||||
wantCandidates := int(wantCompared)
|
||||
if result.Stats.CandidateChunks != wantCandidates || compared.Load() != wantCompared || repeated.Load() != 0 {
|
||||
t.Fatalf("retry candidates=%d compared=%d repeated=%d; want %d,%d,0", result.Stats.CandidateChunks, compared.Load(), repeated.Load(), wantCandidates, wantCompared)
|
||||
}
|
||||
@@ -174,8 +172,8 @@ func TestInterruptedStagingKeepsEqualWork(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result.Stats.CandidateChunks != 1 || retryReads.Load() != int64(8-want) || repeated.Load() != 0 {
|
||||
t.Fatalf("retry candidates=%d reads=%d repeated=%d, want 1,%d,0", result.Stats.CandidateChunks, retryReads.Load(), repeated.Load(), 8-want)
|
||||
if result.Stats.CandidateChunks != 8-want || retryReads.Load() != int64(8-want) || repeated.Load() != 0 {
|
||||
t.Fatalf("retry candidates=%d reads=%d repeated=%d, want %d,%d,0", result.Stats.CandidateChunks, retryReads.Load(), repeated.Load(), 8-want, 8-want)
|
||||
}
|
||||
if !bytes.Equal(blockOf(f.imageOf(t, result.Head), uint32(written*ctChunkBlocks)), makeBlock(ctBlockSize, 0xEC)) {
|
||||
t.Fatal("retry lost the write after the staging read")
|
||||
@@ -183,3 +181,22 @@ func TestInterruptedStagingKeepsEqualWork(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestStagingEqualChunksStillCountAsCandidates(t *testing.T) {
|
||||
_, l, _ := unknownFilledVolume(t)
|
||||
l.cfg.UploadConcurrency = 1
|
||||
l.cfg.COWSpillFree = func() (int64, error) { return 2 * (cowSpillFreeReserve + ctChunkBytes), nil }
|
||||
var reads atomic.Int64
|
||||
l.testAfterStageReadHook = func(uint64) { reads.Add(1) }
|
||||
result, err := l.Cut(ctTimeout(t))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
const total = ctNumBlocks / ctChunkBlocks
|
||||
if reads.Load() != total || result.Stats.StagedChunks != total {
|
||||
t.Fatalf("fixture reads=%d staged=%d, want %d", reads.Load(), result.Stats.StagedChunks, total)
|
||||
}
|
||||
if result.Stats.CandidateChunks != total {
|
||||
t.Fatalf("staging compared %d equal chunks, CandidateChunks=%d, want %d", total, result.Stats.CandidateChunks, total)
|
||||
}
|
||||
}
|
||||
@@ -1070,7 +1070,7 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
|
||||
return chunkCutResult{}, fmt.Errorf("%w: %w: cut LSN %d, HEAD remote_lsn %d", errChunkCaptureRefused, errChunkLSNBehind, h, baseHead.RemoteLSN)
|
||||
}
|
||||
|
||||
st.CandidateChunks = len(candidates)
|
||||
st.CandidateChunks = max(st.CandidateChunks, len(candidates))
|
||||
var copyErr error
|
||||
copyStart := time.Now()
|
||||
bytesBeforeCopy := st.UploadedBytes
|
||||
@@ -1790,6 +1790,7 @@ func (l *chunkLayerImpl) stage(ctx context.Context, st *chunkCutStats, spillCap
|
||||
head := copyHead(l.head)
|
||||
l.stMu.Unlock()
|
||||
st.StageRounds++
|
||||
st.CandidateChunks = max(st.CandidateChunks, len(batch))
|
||||
roundChunks, err := l.stagePayloadRound(ctx, batch, vers, head, st)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user