Skip to content

Commit

Permalink
fix(master): close rocksdb when master shutdown
Browse files Browse the repository at this point in the history
Signed-off-by: NaturalSelect <[email protected]>
  • Loading branch information
NaturalSelect authored and leonrayang committed Sep 15, 2023
1 parent adc8ecc commit 273e2ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion master/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (m *Server) Start(cfg *config.Config) (err error) {
return
}

if m.rocksDBStore, err = raftstore_db.NewRocksDBStore(m.storeDir, LRUCacheSize, WriteBufferSize); err != nil {
if m.rocksDBStore, err = raftstore_db.NewRocksDBStoreAndRecovery(m.storeDir, LRUCacheSize, WriteBufferSize); err != nil {
return
}

Expand Down Expand Up @@ -192,6 +192,9 @@ func (m *Server) Shutdown() {
}
}
stat.CloseStat()
if m.rocksDBStore != nil {
m.rocksDBStore.Close()
}
m.wg.Done()
}

Expand Down
4 changes: 2 additions & 2 deletions raftstore/raftstore_db/store_rocksdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ func NewRocksDBStoreAndRecovery(dir string, lruCacheSize, writeBufferSize int) (
if !fileutil.ExistDir(dir) && fileutil.ExistDir(recoverDir) {
// we move temp dir to rocksdb dir for commiting transaction
if err = os.Rename(recoverDir, dir); err != nil {
log.LogErrorf("failed to rename rocksdb recovery dir %v", err.Error())
log.LogErrorf("action[NewRocksDBStoreAndRecovery]failed to rename rocksdb recovery dir %v", err.Error())
return
}
log.LogDebug("recovery rocksdb success")
log.LogDebug("action[NewRocksDBStoreAndRecovery]recovery rocksdb success")
} else if err = os.MkdirAll(dir, os.ModePerm); err != nil {
return
}
Expand Down

0 comments on commit 273e2ea

Please sign in to comment.