From 074b7cc0ea6594377201a9c8ba2b74da2daafa5c Mon Sep 17 00:00:00 2001 From: pingqiu Date: Thu, 19 Nov 2026 10:04:35 -0800 Subject: [PATCH] fix: wake hydration callers on close while retaining physical I/O ownership --- seaweed-block/core/storage/chunk_hydration.go | 5 +++++ seaweed-block/core/storage/walstore.go | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/seaweed-block/core/storage/chunk_hydration.go b/seaweed-block/core/storage/chunk_hydration.go index b895b81857..f8261fa58e 100644 --- a/seaweed-block/core/storage/chunk_hydration.go +++ b/seaweed-block/core/storage/chunk_hydration.go @@ -88,6 +88,11 @@ func (l *chunkLayerImpl) OnReadMissContext(ctx context.Context, lba uint64) ([]b hook(idx) } select { + case <-l.ctx.Done(): + l.stMu.Lock() + f.waiters-- + l.stMu.Unlock() + return nil, errChunkLayerClosed case <-f.done: case <-ctx.Done(): // A completed fault wins a simultaneous caller deadline. diff --git a/seaweed-block/core/storage/walstore.go b/seaweed-block/core/storage/walstore.go index f2b6d3efa4..9b96bcbc6d 100644 --- a/seaweed-block/core/storage/walstore.go +++ b/seaweed-block/core/storage/walstore.go @@ -1048,9 +1048,15 @@ func (s *WALStore) WriteInstrumentation() WriteInstrumentationStatus { // from the WAL; clean LBAs are served from the extent. func (s *WALStore) Read(lba uint32) ([]byte, error) { return s.ReadContext(context.Background(), lba) } -func (s *WALStore) ReadContext(ctx context.Context, lba uint32) ([]byte, error) { +func (s *WALStore) ReadContext(ctx context.Context, lba uint32) (data []byte, err error) { ctx, cancel := context.WithTimeout(ctx, defaultHydrationWait) defer cancel() + defer func() { + if err == nil && ctx.Err() != nil { + data = nil + err = hydrationPending(ctx.Err()) + } + }() if err := ctx.Err(); err != nil { return nil, hydrationPending(err) }