[#645] badgerstore: Add logger.
All checks were successful
DCO action / DCO (pull_request) Successful in 1m26s
Build / Build Components (1.21) (pull_request) Successful in 4m17s
Build / Build Components (1.20) (pull_request) Successful in 4m22s
Vulncheck / Vulncheck (pull_request) Successful in 3m43s
Tests and linters / Staticcheck (pull_request) Successful in 5m27s
Tests and linters / Lint (pull_request) Successful in 5m52s
Tests and linters / Tests (1.21) (pull_request) Successful in 6m16s
Tests and linters / Tests (1.20) (pull_request) Successful in 6m50s
Tests and linters / Tests with -race (pull_request) Successful in 7m49s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m26s
Build / Build Components (1.21) (pull_request) Successful in 4m17s
Build / Build Components (1.20) (pull_request) Successful in 4m22s
Vulncheck / Vulncheck (pull_request) Successful in 3m43s
Tests and linters / Staticcheck (pull_request) Successful in 5m27s
Tests and linters / Lint (pull_request) Successful in 5m52s
Tests and linters / Tests (1.21) (pull_request) Successful in 6m16s
Tests and linters / Tests (1.20) (pull_request) Successful in 6m50s
Tests and linters / Tests with -race (pull_request) Successful in 7m49s
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
e7c379044f
commit
dc5b741b1d
3 changed files with 17 additions and 1 deletions
|
@ -515,5 +515,6 @@ const (
|
|||
RuntimeSoftMemoryDefinedWithGOMEMLIMIT = "soft runtime memory defined with GOMEMLIMIT environment variable, config value skipped"
|
||||
FailedToCountWritecacheItems = "failed to count writecache items"
|
||||
AttemtToCloseAlreadyClosedBlobovnicza = "attempt to close an already closed blobovnicza"
|
||||
BadgerStoreGCFailed = "failed to run GC on badgerstore"
|
||||
FailedToGetContainerCounters = "failed to get container counters values"
|
||||
)
|
||||
|
|
|
@ -6,8 +6,10 @@ import (
|
|||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/compression"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
"github.com/dgraph-io/badger/v4/options"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type cfg struct {
|
||||
|
@ -17,6 +19,7 @@ type cfg struct {
|
|||
gcTimeout time.Duration
|
||||
gcDiscardRatio float64
|
||||
metrics Metrics
|
||||
logger *logger.Logger
|
||||
}
|
||||
|
||||
type Option func(*cfg)
|
||||
|
@ -52,11 +55,12 @@ func defaultCfg() *cfg {
|
|||
opts.ValueThreshold = 0 // to store all values in vLog
|
||||
|
||||
return &cfg{
|
||||
permissions: 0700,
|
||||
permissions: 0o700,
|
||||
db: opts,
|
||||
gcTimeout: 10 * time.Minute,
|
||||
gcDiscardRatio: 0.2, // for 1GB vLog file GC will perform only if around 200MB could be free
|
||||
metrics: &noopMetrics{},
|
||||
logger: &logger.Logger{Logger: zap.L()},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,3 +127,10 @@ func WithMetrics(m Metrics) Option {
|
|||
c.metrics = m
|
||||
}
|
||||
}
|
||||
|
||||
// WithLogger sets logger.
|
||||
func WithLogger(l *logger.Logger) Option {
|
||||
return func(c *cfg) {
|
||||
c.logger = l
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util"
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Close implements common.Storage.
|
||||
|
@ -61,6 +63,8 @@ func (s *Store) startGC() {
|
|||
case <-t.C:
|
||||
if err := s.db.RunValueLogGC(s.cfg.gcDiscardRatio); err == nil {
|
||||
_ = s.db.RunValueLogGC(s.cfg.gcDiscardRatio) // see https://dgraph.io/docs/badger/get-started/#garbage-collection
|
||||
} else {
|
||||
s.cfg.logger.Error(logs.BadgerStoreGCFailed, zap.Error(err), zap.String("path", s.cfg.db.Dir))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in a new issue