diff --git a/seaweed-block/core/storage/chunk_staging_equal_test.go b/seaweed-block/core/storage/chunk_staging_equal_test.go index ddc0164f3a..79da8e70eb 100644 --- a/seaweed-block/core/storage/chunk_staging_equal_test.go +++ b/seaweed-block/core/storage/chunk_staging_equal_test.go @@ -3,6 +3,7 @@ package storage import ( "bytes" "errors" + "sync/atomic" "testing" ) @@ -37,10 +38,10 @@ func TestRefusedFullCutStagesOnlyTheUnmarkedChunk(t *testing.T) { // The next pass can expose less than one chunk at its barrier. Staging // therefore has to process every actual candidate, making its count exact. l.cfg.COWSpillFree = func() (int64, error) { return 2 * (cowSpillFreeReserve + ctChunkBytes), nil } - comparedAgain := 0 + var comparedAgain atomic.Int64 l.testAfterCompareHook = func(idx uint64) { if marked[idx] { - comparedAgain++ + comparedAgain.Add(1) } } result, err := l.Cut(ctTimeout(t)) @@ -50,8 +51,8 @@ func TestRefusedFullCutStagesOnlyTheUnmarkedChunk(t *testing.T) { if result.Stats.StagedChunks != 1 { t.Fatalf("retry staged %d chunks, want only the one unmarked chunk", result.Stats.StagedChunks) } - if comparedAgain != 0 || result.Stats.CandidateChunks != 1 { - t.Fatalf("retry compared %d candidates (%d already equal), want 1 and 0", result.Stats.CandidateChunks, comparedAgain) + if comparedAgain.Load() != 0 || result.Stats.CandidateChunks != 1 { + t.Fatalf("retry compared %d candidates (%d already equal), want 1 and 0", result.Stats.CandidateChunks, comparedAgain.Load()) } if !bytes.Equal(blockOf(f.imageOf(t, result.Head), ctChunkBlocks+1), want) { t.Fatal("retry lost changed bytes")