Skip to content

Commit

Permalink
storage: Avoid RocksDB error log in in-mem DB open
Browse files Browse the repository at this point in the history
Since #36408 we are propagating some RocksDB logs to Cockroach logs. One
of the cases RocksDB logs an error is when a DB is opened on a directory
that does not yet exist, even though RocksDB is able to create the
directory and succeed at opening a new DB. To avoid seeing this error
log, though, we can simply create the directory before opening the DB.

Release note: None
  • Loading branch information
ajkr committed Apr 10, 2019
1 parent 7669ac5 commit 96545d8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions c-deps/libroach/db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ DBStatus DBOpen(DBEngine** db, DBSlice dir, DBOptions db_opts) {
auto memenv = rocksdb::NewMemEnv(rocksdb::Env::Default());
// Register it for deletion.
env_mgr->TakeEnvOwnership(memenv);
// Create a root directory to suppress error messages that RocksDB would
// print if it had to create the DB directory itself.
memenv->CreateDir("/");
// Make it the env that all other Envs must wrap.
env_mgr->base_env = memenv;
// Make it the env for rocksdb.
Expand Down

0 comments on commit 96545d8

Please sign in to comment.