add max manifest file size for rocksdb (#312)

This commit is contained in:
siddontang 2017-07-31 09:51:35 +08:00 committed by GitHub
parent 0cb8e1a348
commit f49ad4d5ed
4 changed files with 9 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import (
"sync"
"fmt"
"github.com/pelletier/go-toml"
"github.com/siddontang/go/ioutil2"
)
@ -61,6 +62,7 @@ type RocksDBConfig struct {
BackgroundThreads int `toml:"background_theads"`
HighPriorityBackgroundThreads int `toml:"high_priority_background_threads"`
DisableWAL bool `toml:"disable_wal"`
MaxManifestFileSize int `toml:"max_manifest_file_size"`
}
type LMDBConfig struct {
@ -264,6 +266,7 @@ func (cfg *RocksDBConfig) adjust() {
cfg.StatsDumpPeriodSec = getDefault(3600, cfg.StatsDumpPeriodSec)
cfg.BackgroundThreads = getDefault(2, cfg.BackgroundThreads)
cfg.HighPriorityBackgroundThreads = getDefault(1, cfg.HighPriorityBackgroundThreads)
cfg.MaxManifestFileSize = getDefault(20*MB, cfg.MaxManifestFileSize)
}
func (cfg *Config) Dump(w io.Writer) error {

View File

@ -106,6 +106,7 @@ stats_dump_period_sec = 3600
# you can set true if replication opened, we may recover from replication log,
# but it is still not a easy work.
disable_wal = false
max_manifest_file_size = 20971520
[lmdb]
map_size = 524288000

View File

@ -145,6 +145,7 @@ func (db *DB) initOptions(cfg *config.RocksDBConfig) {
opts.EnableStatistics(cfg.EnableStatistics)
opts.UseFsync(cfg.UseFsync)
opts.SetStatsDumpPeriodSec(cfg.StatsDumpPeriodSec)
opts.SetMaxManifestFileSize(cfg.MaxManifestFileSize)
db.opts = opts
db.blockOpts = blockOpts

View File

@ -168,6 +168,10 @@ func (o *Options) SetStatsDumpPeriodSec(n int) {
C.rocksdb_options_set_stats_dump_period_sec(o.Opt, C.uint(n))
}
func (o *Options) SetMaxManifestFileSize(n int) {
C.rocksdb_options_set_max_manifest_file_size(o.Opt, C.size_t(n))
}
func (o *BlockBasedTableOptions) Close() {
C.rocksdb_block_based_options_destroy(o.Opt)
}