diff --git a/seaweed-block/core/frontend/durable/storage_adapter.go b/seaweed-block/core/frontend/durable/storage_adapter.go index 70c049839b..10f156e3fb 100644 --- a/seaweed-block/core/frontend/durable/storage_adapter.go +++ b/seaweed-block/core/frontend/durable/storage_adapter.go @@ -804,6 +804,10 @@ func (b *StorageBackend) readStorageBlock(ctx context.Context, lba uint32) ([]by } func hydrationPendingOnly(err error) bool { + return errors.Is(err, storage.ErrChunkHydrationPending) && hydrationPendingCauseOnly(err) +} + +func hydrationPendingCauseOnly(err error) bool { if err == storage.ErrChunkHydrationPending || err == context.DeadlineExceeded || err == context.Canceled { return true } @@ -816,13 +820,13 @@ func hydrationPendingOnly(err error) bool { return false } for _, cause := range causes { - if !hydrationPendingOnly(cause) { + if !hydrationPendingCauseOnly(cause) { return false } } return true } - return hydrationPendingOnly(errors.Unwrap(err)) + return hydrationPendingCauseOnly(errors.Unwrap(err)) } // readBytes performs the byte-range → LBA-range fanout for Read. diff --git a/seaweed-block/core/storage/chunk_hydration.go b/seaweed-block/core/storage/chunk_hydration.go index 9d462e5baf..01cd469c4e 100644 --- a/seaweed-block/core/storage/chunk_hydration.go +++ b/seaweed-block/core/storage/chunk_hydration.go @@ -159,6 +159,9 @@ func (l *chunkLayerImpl) hydrationWorker() { cancel() next.cancel() l.stMu.Lock() + if hydrationContextCauseOnly(err) { + err = hydrationPending(err) + } next.err = err delete(l.hydration, next.idx) close(next.done) @@ -179,3 +182,27 @@ func (l *chunkLayerImpl) closeHydrationLocked() { } } } + +// Joined physical/unknown errors must not become retryable just because they +// also contain a context cause. +func hydrationContextCauseOnly(err error) bool { + if err == context.DeadlineExceeded || err == context.Canceled { + return true + } + if err == nil { + return false + } + if j, ok := err.(interface{ Unwrap() []error }); ok { + causes := j.Unwrap() + if len(causes) == 0 { + return false + } + for _, cause := range causes { + if !hydrationContextCauseOnly(cause) { + return false + } + } + return true + } + return hydrationContextCauseOnly(errors.Unwrap(err)) +}