From 76e56fc6cdba9d0e3d7be40442dbe58b6afc38f4 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Sat, 21 Nov 2026 16:25:45 -0800 Subject: [PATCH] durable: log when a detach's I/O stop began (the operational flip), next to when StopIO returned A guest error after the flip is a refusal by contract; only an error on I/O admitted before the flip is a data-path failure. The detach now logs 'I/O stop began at' (taken just before the flip: plain stop, live StopIO, or the pre-copy TryStopIO) beside 'StopIO returned at', both RFC 3339 nanoseconds, so a measurement can count from the flip (#375). Co-Authored-By: Claude Opus 5.5 --- .../core/frontend/durable/provider_chunk.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/seaweed-block/core/frontend/durable/provider_chunk.go b/seaweed-block/core/frontend/durable/provider_chunk.go index e7a877d293..118aaab786 100644 --- a/seaweed-block/core/frontend/durable/provider_chunk.go +++ b/seaweed-block/core/frontend/durable/provider_chunk.go @@ -1121,10 +1121,17 @@ func (p *DurableProvider) detachVolume(ctx context.Context, volumeID string, pla // the cut gets three quarters, the settlement what is left. The bound is // cooperative (contexts): a syscall that never returns is not bounded here. var start time.Time - var stopIOReturned time.Time + // stopIOBegan is taken just before the operational flip (from then on new + // I/O is refused by contract), stopIOReturned when the admitted I/O has + // drained; both are logged so a measurement can tell a refusal after the + // flip from an admitted I/O that failed. + var stopIOBegan, stopIOReturned time.Time defer func() { if !stopIOReturned.IsZero() { - // Emit after the cut releases its barrier, using the actual return time. + // Emit after the cut releases its barrier, using the actual times. + if !stopIOBegan.IsZero() { + log.Printf("durable: volume=%s I/O stop began at %s", volumeID, stopIOBegan.UTC().Format(time.RFC3339Nano)) + } log.Printf("durable: volume=%s StopIO returned at %s", volumeID, stopIOReturned.UTC().Format(time.RFC3339Nano)) } }() @@ -1194,10 +1201,11 @@ func (p *DurableProvider) detachVolume(ctx context.Context, volumeID string, pla // Cancel/join the periodic owner before any final freeze, while serving. p.stopChunkLoop(h) r, err = owner.PrecopyDetachWithAdmission(hostlimit.WithClass(cutCtx, hostlimit.Urgent), h.backend.BeginPrecopyPause, func() bool { + began := time.Now() if !h.backend.TryStopIO("chunk pre-copy: final detached cut") { return false } - stopIOReturned = time.Now() + stopIOBegan, stopIOReturned = began, time.Now() h.chunkDetach = true beginFreeze() return true @@ -1238,6 +1246,7 @@ func (p *DurableProvider) detachVolume(ctx context.Context, volumeID string, pla } } else { beginFreeze() + stopIOBegan = time.Now() if plain { if err := h.backend.stopPlainDetachIfIdle(); err != nil { return r, 0, err