pebble: Set default format_major_version to the newest
Additionally, add a warning when not using the newest version.
This commit is contained in:
parent
19d1ab3d3f
commit
61644365e0
|
@ -66,7 +66,8 @@ var (
|
||||||
// DefaultFilterPolicy defines the number of bits used per key for
|
// DefaultFilterPolicy defines the number of bits used per key for
|
||||||
// bloom filters. 10 yields a 1% false positive rate.
|
// bloom filters. 10 yields a 1% false positive rate.
|
||||||
DefaultFilterPolicy bloom.FilterPolicy = 10 // Pebble's default: 10
|
DefaultFilterPolicy bloom.FilterPolicy = 10 // Pebble's default: 10
|
||||||
|
// DefaultFormatMajorVersion sets the format of Pebble on-disk files.
|
||||||
|
DefaultFormatMajorVersion = pebble.FormatNewest
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -219,6 +220,7 @@ func (cfg *Config) Default() error {
|
||||||
cfg.PebbleOptions = DefaultPebbleOptions
|
cfg.PebbleOptions = DefaultPebbleOptions
|
||||||
cache := pebble.NewCache(DefaultCacheSize)
|
cache := pebble.NewCache(DefaultCacheSize)
|
||||||
cfg.PebbleOptions.Cache = cache
|
cfg.PebbleOptions.Cache = cache
|
||||||
|
cfg.PebbleOptions.FormatMajorVersion = DefaultFormatMajorVersion
|
||||||
cfg.PebbleOptions.MemTableSize = DefaultMemTableSize
|
cfg.PebbleOptions.MemTableSize = DefaultMemTableSize
|
||||||
cfg.PebbleOptions.MemTableStopWritesThreshold = DefaultMemTableStopWritesThreshold
|
cfg.PebbleOptions.MemTableStopWritesThreshold = DefaultMemTableStopWritesThreshold
|
||||||
cfg.PebbleOptions.BytesPerSync = DefaultBytesPerSync
|
cfg.PebbleOptions.BytesPerSync = DefaultBytesPerSync
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/cockroachdb/pebble"
|
||||||
ds "github.com/ipfs/go-datastore"
|
ds "github.com/ipfs/go-datastore"
|
||||||
pebbleds "github.com/ipfs/go-ds-pebble"
|
pebbleds "github.com/ipfs/go-ds-pebble"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
|
@ -24,6 +25,19 @@ func New(cfg *Config) (ds.Datastore, error) {
|
||||||
return nil, errors.Wrap(err, "creating pebble folder")
|
return nil, errors.Wrap(err, "creating pebble folder")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deal with Pebble updates... user should try to be up to date with
|
||||||
|
// latest Pebble table formats.
|
||||||
|
fmv := cfg.PebbleOptions.FormatMajorVersion
|
||||||
|
newest := pebble.FormatNewest
|
||||||
|
if fmv < newest {
|
||||||
|
logger.Warnf(`Pebble's format_major_version is set to %d, but newest version is %d.
|
||||||
|
|
||||||
|
It is recommended to increase format_major_version and restart. If an error
|
||||||
|
occurrs when increasing the number several versions at once, it may help to
|
||||||
|
increase them one by one, restarting the daemon every time.
|
||||||
|
`, fmv, newest)
|
||||||
|
}
|
||||||
|
|
||||||
db, err := pebbleds.NewDatastore(folder, &cfg.PebbleOptions)
|
db, err := pebbleds.NewDatastore(folder, &cfg.PebbleOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -32,11 +46,13 @@ func New(cfg *Config) (ds.Datastore, error) {
|
||||||
// Calling regularly DB's DiskUsage is a way to printout debug
|
// Calling regularly DB's DiskUsage is a way to printout debug
|
||||||
// database statistics.
|
// database statistics.
|
||||||
go func() {
|
go func() {
|
||||||
|
ctx := context.Background()
|
||||||
|
db.DiskUsage(ctx)
|
||||||
ticker := time.NewTicker(time.Minute)
|
ticker := time.NewTicker(time.Minute)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
for {
|
for {
|
||||||
<-ticker.C
|
<-ticker.C
|
||||||
db.DiskUsage(context.Background())
|
db.DiskUsage(ctx)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
return db, nil
|
return db, nil
|
||||||
|
|
Loading…
Reference in New Issue
Block a user