fix: keep physical causes terminal when hydration deadlines expire

This commit is contained in:
pingqiu committed 2026-11-19 16:02:10 -08:00
1 parent 3c7cef087d
commit 2b2ac682ee
2 files changed
+33 -2

No files matched your search

@@ -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.
@@ -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))
}