From 57d60b0ce019e060fd993e8ad994e7ff7c30de77 Mon Sep 17 00:00:00 2001 From: siddontang Date: Fri, 24 Oct 2014 23:30:27 +0800 Subject: [PATCH] add disable wal config for rocksdb --- config/config.go | 2 ++ config/config.toml | 5 ++++- etc/ledis.conf | 5 ++++- store/rocksdb/db.go | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) 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)