Merge pull request #2019 from ipfs-cluster/pebble-major-format-version
pebble: Set default format_major_version to the newest Attempts to fix issues as Pebble will stop supporting the older versions and we will be upgrading Pebble in the future. In the meantime we need to attempt that users upgrade to v14 (I think).
This commit is contained in:
commit
ad0f46dd40
|
@ -66,7 +66,8 @@ var (
|
|||
// DefaultFilterPolicy defines the number of bits used per key for
|
||||
// bloom filters. 10 yields a 1% false positive rate.
|
||||
DefaultFilterPolicy bloom.FilterPolicy = 10 // Pebble's default: 10
|
||||
|
||||
// DefaultFormatMajorVersion sets the format of Pebble on-disk files.
|
||||
DefaultFormatMajorVersion = pebble.FormatNewest
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -219,6 +220,7 @@ func (cfg *Config) Default() error {
|
|||
cfg.PebbleOptions = DefaultPebbleOptions
|
||||
cache := pebble.NewCache(DefaultCacheSize)
|
||||
cfg.PebbleOptions.Cache = cache
|
||||
cfg.PebbleOptions.FormatMajorVersion = DefaultFormatMajorVersion
|
||||
cfg.PebbleOptions.MemTableSize = DefaultMemTableSize
|
||||
cfg.PebbleOptions.MemTableStopWritesThreshold = DefaultMemTableStopWritesThreshold
|
||||
cfg.PebbleOptions.BytesPerSync = DefaultBytesPerSync
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/cockroachdb/pebble"
|
||||
ds "github.com/ipfs/go-datastore"
|
||||
pebbleds "github.com/ipfs/go-ds-pebble"
|
||||
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")
|
||||
}
|
||||
|
||||
// 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)
|
||||
if err != nil {
|
||||
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
|
||||
// database statistics.
|
||||
go func() {
|
||||
ctx := context.Background()
|
||||
db.DiskUsage(ctx)
|
||||
ticker := time.NewTicker(time.Minute)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
<-ticker.C
|
||||
db.DiskUsage(context.Background())
|
||||
db.DiskUsage(ctx)
|
||||
}
|
||||
}()
|
||||
return db, nil
|
||||
|
|
Loading…
Reference in New Issue
Block a user