diff --git a/config/config.go b/config/config.go index 72c3105..551a798 100644 --- a/config/config.go +++ b/config/config.go @@ -59,6 +59,7 @@ type RocksDBConfig struct { StatsDumpPeriodSec int `toml:"stats_dump_period_sec"` BackgroundThreads int `toml:"background_theads"` HighPriorityBackgroundThreads int `toml:"high_priority_background_threads"` + DisableWAL bool `toml:"disable_wal"` } type LMDBConfig struct { @@ -169,6 +170,7 @@ func NewConfigDefault() *Config { cfg.RocksDB.UseFsync = false cfg.RocksDB.DisableAutoCompactions = false cfg.RocksDB.AllowOsBuffer = true + cfg.RocksDB.DisableWAL = false cfg.adjust() diff --git a/config/config.toml b/config/config.toml index 88f566b..a3b0833 100644 --- a/config/config.toml +++ b/config/config.toml @@ -82,7 +82,10 @@ max_background_flushes = 1 allow_os_buffer = true enable_statistics = false 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] map_size = 524288000 diff --git a/etc/ledis.conf b/etc/ledis.conf index 88f566b..a3b0833 100644 --- a/etc/ledis.conf +++ b/etc/ledis.conf @@ -82,7 +82,10 @@ max_background_flushes = 1 allow_os_buffer = true enable_statistics = false 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] map_size = 524288000 diff --git a/store/rocksdb/db.go b/store/rocksdb/db.go index 9bc7898..e1f10a4 100644 --- a/store/rocksdb/db.go +++ b/store/rocksdb/db.go @@ -150,9 +150,11 @@ func (db *DB) initOptions(cfg *config.RocksDBConfig) { db.readOpts = NewReadOptions() db.writeOpts = NewWriteOptions() + db.writeOpts.DisableWAL(cfg.DisableWAL) db.syncOpts = NewWriteOptions() db.syncOpts.SetSync(true) + db.syncOpts.DisableWAL(cfg.DisableWAL) db.iteratorOpts = NewReadOptions() db.iteratorOpts.SetFillCache(false)