forked from TrueCloudLab/frostfs-node
[#598] Fix use-after-close bug in badger writecache
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
ae8be495c8
commit
88b6755c5e
2 changed files with 15 additions and 0 deletions
|
@ -20,6 +20,14 @@ func (c *cache) runGCLoop() {
|
|||
case <-c.closeCh:
|
||||
return
|
||||
case <-t.C:
|
||||
// This serves to synchronize the c.db field when changing mode as well.
|
||||
c.modeMtx.RLock()
|
||||
ro := c.readOnly()
|
||||
c.modeMtx.RUnlock()
|
||||
if ro {
|
||||
continue
|
||||
}
|
||||
|
||||
// 0.5 is the recommended value so that write amplification of the value log is 2.
|
||||
// See https://pkg.go.dev/github.com/dgraph-io/badger/v4#DB.RunValueLogGC for more info.
|
||||
for c.db.RunValueLogGC(0.5) == nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue