Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache: fix buffer conflict in writeback mode #5563

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func storageFlags() []cli.Flag {
},
&cli.IntFlag{
Name: "max-stage-write",
Value: 0, // Enable this to have concurrent uploads to two backends, and get write bandwidth equals to sum of the two
Value: 1000, // large enough for normal cases, also prevents unlimited concurrency in abnormal cases
Usage: "number of threads allowed to write staged files, other requests will be uploaded directly (this option is only effective when 'writeback' mode is enabled)",
},
&cli.IntFlag{
Expand Down
9 changes: 5 additions & 4 deletions pkg/chunk/cached_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ func (s *wSlice) upload(indx int) {
}
if s.store.conf.Writeback {
stagingPath := "unknown"
block.Acquire()
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`
defer block.Release()
stagingPath, err = s.store.bcache.stage(key, block.Data, s.store.shouldCache(blen))
return err
}, s.store.conf.PutTimeout)
Expand Down Expand Up @@ -590,10 +592,6 @@ func (c *Config) SelfCheck(uuid string) {
c.UploadDelay = 0
c.UploadHours = ""
}
if c.MaxStageWrite > 0 {
logger.Warnf("max-stage-write is disabled in non-writeback mode")
c.MaxStageWrite = 0
}
}
if _, _, err := c.parseHours(); err != nil {
logger.Warnf("invalid value (%s) for upload-hours: %s", c.UploadHours, err)
Expand All @@ -617,6 +615,9 @@ func (c *Config) SelfCheck(uuid string) {
logger.Warnf("verify-cache-checksum should be one of %v", cs)
c.CacheChecksum = CsFull
}
} else if c.Writeback {
logger.Warnf("writeback is not supported in memory cache mode")
c.Writeback = false
}
if c.CacheEviction == "" {
c.CacheEviction = "2-random"
Expand Down
Loading