Skip to content

Commit

Permalink
Add timeout for stage writings to avoid EIO when it hangs for more th…
Browse files Browse the repository at this point in the history
…an 5 minutes (#5230)

Signed-off-by: Changxin Miao <[email protected]>
  • Loading branch information
polyrabbit authored Oct 22, 2024
1 parent ddd82ed commit 13b1f1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/chunk/cached_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ func (s *wSlice) upload(indx int) {
panic(fmt.Sprintf("block length does not match: %v != %v", off, blen))
}
if s.store.conf.Writeback {
stagingPath, err := s.store.bcache.stage(key, block.Data, s.store.shouldCache(blen))
stagingPath := "unknown"
err := utils.WithTimeout(func() (err error) { // In case it hangs for more than 5 minutes(see fileWriter.flush), fallback to uploading directly to avoid `EIO`
stagingPath, err = s.store.bcache.stage(key, block.Data, s.store.shouldCache(blen))
return err
}, s.store.conf.PutTimeout)
if err != nil {
if !errors.Is(err, errStageConcurrency) {
s.store.stageBlockErrors.Add(1)
Expand Down

0 comments on commit 13b1f1d

Please sign in to comment.