enable truncate value log option if badger db offset is different from badger db size (#128)
* enable truncate option in badger to cleanup inconsistent data due to application crashes * updated as per review comments
This commit is contained in:
Родитель
db1c117b71
Коммит
b671cfe028
|
@ -69,6 +69,7 @@ type SloopConfig struct {
|
|||
BadgerNumL0TablesStall int `json:"badgerNumLevelZeroTables"`
|
||||
BadgerSyncWrites bool `json:"badgerSyncWrites"`
|
||||
BadgerVLogFileIOMapping bool `json:"badgerVLogFileIOMapping"`
|
||||
BadgerVLogTruncate bool `json:"badgerVLogTruncate"`
|
||||
EnableDeleteKeys bool `json:"enableDeleteKeys"`
|
||||
}
|
||||
|
||||
|
@ -115,6 +116,7 @@ func registerFlags(fs *flag.FlagSet, config *SloopConfig) {
|
|||
fs.BoolVar(&config.BadgerSyncWrites, "badger-sync-writes", true, "Sync Writes ensures writes are synced to disk if set to true")
|
||||
fs.BoolVar(&config.EnableDeleteKeys, "enable-delete-keys", false, "Use delete prefixes instead of dropPrefix for GC")
|
||||
fs.BoolVar(&config.BadgerVLogFileIOMapping, "badger-vlog-fileIO-mapping", false, "Indicates which file loading mode should be used for the value log data, in memory constrained environments the value is recommended to be true")
|
||||
fs.BoolVar(&config.BadgerVLogTruncate, "badger-vlog-truncate", true, "Truncate value log if badger db offset is different from badger db size")
|
||||
}
|
||||
|
||||
// This will first check if a config file is specified on cmd line using a temporary flagSet
|
||||
|
|
|
@ -73,6 +73,7 @@ func RealMain() error {
|
|||
BadgerLevelOneSize: conf.BadgerLevelOneSize,
|
||||
BadgerLevSizeMultiplier: conf.BadgerLevSizeMultiplier,
|
||||
BadgerVLogFileIOMapping: conf.BadgerVLogFileIOMapping,
|
||||
BadgerVLogTruncate: conf.BadgerVLogTruncate,
|
||||
}
|
||||
db, err := untyped.OpenStore(factory, storeConfig)
|
||||
if err != nil {
|
||||
|
|
|
@ -9,7 +9,7 @@ package untyped
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
badger "github.com/dgraph-io/badger/v2"
|
||||
"github.com/dgraph-io/badger/v2"
|
||||
"github.com/dgraph-io/badger/v2/options"
|
||||
"github.com/golang/glog"
|
||||
"github.com/salesforce/sloop/pkg/sloop/store/untyped/badgerwrap"
|
||||
|
@ -33,6 +33,7 @@ type Config struct {
|
|||
BadgerLevelOneSize int64
|
||||
BadgerLevSizeMultiplier int
|
||||
BadgerVLogFileIOMapping bool
|
||||
BadgerVLogTruncate bool
|
||||
}
|
||||
|
||||
func OpenStore(factory badgerwrap.Factory, config *Config) (badgerwrap.DB, error) {
|
||||
|
@ -94,6 +95,8 @@ func OpenStore(factory badgerwrap.Factory, config *Config) (badgerwrap.DB, error
|
|||
opts = opts.WithValueLogLoadingMode(options.FileIO)
|
||||
}
|
||||
|
||||
opts = opts.WithTruncate(config.BadgerVLogTruncate)
|
||||
|
||||
opts = opts.WithSyncWrites(config.BadgerSyncWrites)
|
||||
|
||||
db, err := factory.Open(opts)
|
||||
|
|
Загрузка…
Ссылка в новой задаче