Skip to content

Commit

Permalink
storage: change default engine type from RocksDB to Pebble
Browse files Browse the repository at this point in the history
This flips the switch to use Pebble by default. This will cause all
tests which don't explicitly specify RocksDB (i.e. the vast majority) to
now use Pebble. One exception is certain roachtests which create store
directories using older versions of CRDB and then upgrade to the current
version. Those tests will continue to use RocksDB (for now) due to the
nature of how `--storage-engine=...` is "sticky" if not specified,
defaulting to the previously used storage engine.

Release note (general change): Change the default engine type for new
storage directories from RocksDB to Pebble. Existing stores will
continue to use the previously specified storage engine, and an explicit
specification (via `--storage-engine=...`) will override the default.
  • Loading branch information
petermattis committed May 6, 2020
1 parent 2cc13d4 commit 3506ed1
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,12 @@ func initTempStorageConfig(
// a store wasn't found).
func resolveStorageEngineType(engineType enginepb.EngineType, dir string) enginepb.EngineType {
if engineType == enginepb.EngineTypeDefault {
engineType = enginepb.EngineTypeRocksDB
engineType = enginepb.EngineTypePebble
// Check if this storage directory was last written to by pebble. In that
// case, default to opening a Pebble engine.
if version, err := pebble.GetVersion(dir, vfs.Default); err == nil {
if version != "" && !strings.HasPrefix(version, "rocksdb") {
engineType = enginepb.EngineTypePebble
if strings.HasPrefix(version, "rocksdb") {
engineType = enginepb.EngineTypeRocksDB
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/below_raft_protos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ var belowRaftGoldenProtos = map[reflect.Type]fixture{
}

func init() {
if storage.DefaultStorageEngine != enginepb.EngineTypeRocksDB && storage.DefaultStorageEngine != enginepb.EngineTypeDefault {
if storage.DefaultStorageEngine != enginepb.EngineTypeRocksDB {
// These are marshaled below Raft by the Pebble merge operator. The Pebble
// merge operator can be called below Raft whenever a Pebble Iterator is
// used. Note that we only see these protos marshaled below Raft when the
Expand Down
10 changes: 5 additions & 5 deletions pkg/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,13 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {

var cache storage.RocksDBCache
var pebbleCache *pebble.Cache
if cfg.StorageEngine == enginepb.EngineTypePebble || cfg.StorageEngine == enginepb.EngineTypeTeePebbleRocksDB {
if cfg.StorageEngine == enginepb.EngineTypeDefault ||
cfg.StorageEngine == enginepb.EngineTypePebble || cfg.StorageEngine == enginepb.EngineTypeTeePebbleRocksDB {
details = append(details, fmt.Sprintf("Pebble cache size: %s", humanizeutil.IBytes(cfg.CacheSize)))
pebbleCache = pebble.NewCache(cfg.CacheSize)
defer pebbleCache.Unref()
}
if cfg.StorageEngine == enginepb.EngineTypeDefault ||
cfg.StorageEngine == enginepb.EngineTypeRocksDB || cfg.StorageEngine == enginepb.EngineTypeTeePebbleRocksDB {
if cfg.StorageEngine == enginepb.EngineTypeRocksDB || cfg.StorageEngine == enginepb.EngineTypeTeePebbleRocksDB {
details = append(details, fmt.Sprintf("RocksDB cache size: %s", humanizeutil.IBytes(cfg.CacheSize)))
cache = storage.NewRocksDBCache(cfg.CacheSize)
defer cache.Release()
Expand Down Expand Up @@ -518,7 +518,7 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
UseFileRegistry: spec.UseFileRegistry,
ExtraOptions: spec.ExtraOptions,
}
if cfg.StorageEngine == enginepb.EngineTypePebble {
if cfg.StorageEngine == enginepb.EngineTypePebble || cfg.StorageEngine == enginepb.EngineTypeDefault {
// TODO(itsbilal): Tune these options, and allow them to be overridden
// in the spec (similar to the existing spec.RocksDBOptions and others).
pebbleConfig := storage.PebbleConfig{
Expand All @@ -528,7 +528,7 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
pebbleConfig.Opts.Cache = pebbleCache
pebbleConfig.Opts.MaxOpenFiles = int(openFileLimitPerStore)
eng, err = storage.NewPebble(ctx, pebbleConfig)
} else if cfg.StorageEngine == enginepb.EngineTypeRocksDB || cfg.StorageEngine == enginepb.EngineTypeDefault {
} else if cfg.StorageEngine == enginepb.EngineTypeRocksDB {
rocksDBConfig := storage.RocksDBConfig{
StorageConfig: storageConfig,
MaxOpenFiles: openFileLimitPerStore,
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func NewEngine(
}

return NewTee(ctx, rocksDB, pebbleDB), nil
case enginepb.EngineTypePebble:
case enginepb.EngineTypeDefault, enginepb.EngineTypePebble:
pebbleConfig := PebbleConfig{
StorageConfig: storageConfig,
Opts: DefaultPebbleOptions(),
Expand All @@ -573,7 +573,7 @@ func NewEngine(
defer pebbleConfig.Opts.Cache.Unref()

return NewPebble(context.Background(), pebbleConfig)
case enginepb.EngineTypeDefault, enginepb.EngineTypeRocksDB:
case enginepb.EngineTypeRocksDB:
cache := NewRocksDBCache(cacheSize)
defer cache.Release()

Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/in_mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func NewInMem(
switch engine {
case enginepb.EngineTypeTeePebbleRocksDB:
return newTeeInMem(ctx, attrs, cacheSize)
case enginepb.EngineTypePebble:
case enginepb.EngineTypeDefault, enginepb.EngineTypePebble:
return newPebbleInMem(ctx, attrs, cacheSize)
case enginepb.EngineTypeDefault, enginepb.EngineTypeRocksDB:
case enginepb.EngineTypeRocksDB:
return newRocksDBInMem(attrs, cacheSize)
}
panic(fmt.Sprintf("unknown engine type: %d", engine))
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/temp_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ func NewTempEngine(
switch engine {
case enginepb.EngineTypeTeePebbleRocksDB:
fallthrough
case enginepb.EngineTypePebble:
case enginepb.EngineTypeDefault, enginepb.EngineTypePebble:
return NewPebbleTempEngine(ctx, tempStorage, storeSpec)
case enginepb.EngineTypeDefault, enginepb.EngineTypeRocksDB:
case enginepb.EngineTypeRocksDB:
return NewRocksDBTempEngine(tempStorage, storeSpec)
}
panic(fmt.Sprintf("unknown engine type: %d", engine))
Expand Down

0 comments on commit 3506ed1

Please sign in to comment.