From 7d0195d8a7a406a09b25e094e0d1590c4563ee1e Mon Sep 17 00:00:00 2001 From: pingqiu Date: Fri, 20 Nov 2026 04:57:19 -0800 Subject: [PATCH] storage: require real CAS samples for freeze admission --- seaweed-block/core/storage/chunk_precopy.go | 4 ++++ seaweed-block/core/storage/chunk_precopy_detach_test.go | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/storage/chunk_precopy.go b/seaweed-block/core/storage/chunk_precopy.go index 8d3c12cab5..985995073c 100644 --- a/seaweed-block/core/storage/chunk_precopy.go +++ b/seaweed-block/core/storage/chunk_precopy.go @@ -204,6 +204,10 @@ func (l *chunkLayerImpl) precopyEstimate(tail uint64, attempts int) PrecopyRepor } func (l *chunkLayerImpl) samplePrecopy(st chunkCutStats, fixedNs int64) { + // A no-op root read is not a measurement of final CAS + confirmation. + if st.CASNs <= 0 { + return + } s := precopySample{at: time.Now(), fixed: time.Duration(max(int64(1), fixedNs))} if st.UploadedBytes > 0 && st.PayloadNs > 0 { s.rate = float64(st.UploadedBytes) / time.Duration(st.PayloadNs).Seconds() diff --git a/seaweed-block/core/storage/chunk_precopy_detach_test.go b/seaweed-block/core/storage/chunk_precopy_detach_test.go index b707e04699..09278ddf56 100644 --- a/seaweed-block/core/storage/chunk_precopy_detach_test.go +++ b/seaweed-block/core/storage/chunk_precopy_detach_test.go @@ -231,7 +231,8 @@ func TestPrecopyDetachQueuedCancellationReturnsWhileOtherCutOwnsPipeline(t *test _, f, l, _ := precopyLayer(t, 1024, 1) entered, release := holdPuts(t, f) cutDone, preDone := make(chan struct{}), make(chan struct{}) - ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond) + var ctx context.Context + cancel := func() {} var precopyErr error t.Cleanup(func() { release() @@ -251,6 +252,7 @@ func TestPrecopyDetachQueuedCancellationReturnsWhileOtherCutOwnsPipeline(t *test close(preDone) t.Fatal("other cut did not reach held upload") } + ctx, cancel = context.WithTimeout(context.Background(), 100*time.Millisecond) go func() { defer close(preDone) _, precopyErr = l.PrecopyDetach(ctx, func() bool { t.Error("queued canceled caller stopped I/O"); return false })