add disable wal config for rocksdb

This commit is contained in:
siddontang 2014-10-24 23:30:27 +08:00
parent 3c38beb62d
commit 57d60b0ce0
4 changed files with 12 additions and 2 deletions

View File

@ -59,6 +59,7 @@ type RocksDBConfig struct {
StatsDumpPeriodSec int `toml:"stats_dump_period_sec"` StatsDumpPeriodSec int `toml:"stats_dump_period_sec"`
BackgroundThreads int `toml:"background_theads"` BackgroundThreads int `toml:"background_theads"`
HighPriorityBackgroundThreads int `toml:"high_priority_background_threads"` HighPriorityBackgroundThreads int `toml:"high_priority_background_threads"`
DisableWAL bool `toml:"disable_wal"`
} }
type LMDBConfig struct { type LMDBConfig struct {
@ -169,6 +170,7 @@ func NewConfigDefault() *Config {
cfg.RocksDB.UseFsync = false cfg.RocksDB.UseFsync = false
cfg.RocksDB.DisableAutoCompactions = false cfg.RocksDB.DisableAutoCompactions = false
cfg.RocksDB.AllowOsBuffer = true cfg.RocksDB.AllowOsBuffer = true
cfg.RocksDB.DisableWAL = false
cfg.adjust() cfg.adjust()

View File

@ -82,7 +82,10 @@ max_background_flushes = 1
allow_os_buffer = true allow_os_buffer = true
enable_statistics = false enable_statistics = false
stats_dump_period_sec = 3600 stats_dump_period_sec = 3600
# dangerous to set true, write may got lost after a crash
# you can set true if replication opened, we may recover from replication log,
# but it is still not a easy work.
disable_wal = false
[lmdb] [lmdb]
map_size = 524288000 map_size = 524288000

View File

@ -82,7 +82,10 @@ max_background_flushes = 1
allow_os_buffer = true allow_os_buffer = true
enable_statistics = false enable_statistics = false
stats_dump_period_sec = 3600 stats_dump_period_sec = 3600
# dangerous to set true, write may got lost after a crash
# you can set true if replication opened, we may recover from replication log,
# but it is still not a easy work.
disable_wal = false
[lmdb] [lmdb]
map_size = 524288000 map_size = 524288000

View File

@ -150,9 +150,11 @@ func (db *DB) initOptions(cfg *config.RocksDBConfig) {
db.readOpts = NewReadOptions() db.readOpts = NewReadOptions()
db.writeOpts = NewWriteOptions() db.writeOpts = NewWriteOptions()
db.writeOpts.DisableWAL(cfg.DisableWAL)
db.syncOpts = NewWriteOptions() db.syncOpts = NewWriteOptions()
db.syncOpts.SetSync(true) db.syncOpts.SetSync(true)
db.syncOpts.DisableWAL(cfg.DisableWAL)
db.iteratorOpts = NewReadOptions() db.iteratorOpts = NewReadOptions()
db.iteratorOpts.SetFillCache(false) db.iteratorOpts.SetFillCache(false)