[#585] writecache: Fix DB counter
Some checks failed
DCO action / DCO (pull_request) Successful in 2m14s
Vulncheck / Vulncheck (pull_request) Successful in 2m44s
Build / Build Components (1.21) (pull_request) Successful in 2m54s
Build / Build Components (1.20) (pull_request) Successful in 3m5s
Tests and linters / Staticcheck (pull_request) Successful in 3m43s
Tests and linters / Lint (pull_request) Successful in 5m12s
Tests and linters / Tests (1.21) (pull_request) Successful in 7m44s
Tests and linters / Tests (1.20) (pull_request) Successful in 21m5s
Tests and linters / Tests with -race (pull_request) Failing after 26m26s
Some checks failed
DCO action / DCO (pull_request) Successful in 2m14s
Vulncheck / Vulncheck (pull_request) Successful in 2m44s
Build / Build Components (1.21) (pull_request) Successful in 2m54s
Build / Build Components (1.20) (pull_request) Successful in 3m5s
Tests and linters / Staticcheck (pull_request) Successful in 3m43s
Tests and linters / Lint (pull_request) Successful in 5m12s
Tests and linters / Tests (1.21) (pull_request) Successful in 7m44s
Tests and linters / Tests (1.20) (pull_request) Successful in 21m5s
Tests and linters / Tests with -race (pull_request) Failing after 26m26s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
58c8722c81
commit
2efe9cc1be
3 changed files with 31 additions and 5 deletions
|
@ -3,6 +3,7 @@ package writecachebbolt
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
|
@ -68,9 +69,12 @@ func (c *cache) openStore(readOnly bool) error {
|
|||
}
|
||||
|
||||
func (c *cache) deleteFromDB(key string) {
|
||||
var recordDeleted bool
|
||||
err := c.db.Batch(func(tx *bbolt.Tx) error {
|
||||
b := tx.Bucket(defaultBucket)
|
||||
return b.Delete([]byte(key))
|
||||
key := []byte(key)
|
||||
recordDeleted = !recordDeleted && b.Get(key) != nil
|
||||
return b.Delete(key)
|
||||
})
|
||||
|
||||
if err == nil {
|
||||
|
@ -80,7 +84,10 @@ func (c *cache) deleteFromDB(key string) {
|
|||
storagelog.StorageTypeField(wcStorageType),
|
||||
storagelog.OpField("db DELETE"),
|
||||
)
|
||||
c.estimateCacheSize()
|
||||
if recordDeleted {
|
||||
c.objCounters.cDB.Add(math.MaxUint64)
|
||||
c.estimateCacheSize()
|
||||
}
|
||||
} else {
|
||||
c.log.Error(logs.WritecacheCantRemoveObjectsFromTheDatabase, zap.Error(err))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue