rocksdb icon indicating copy to clipboard operation
rocksdb copied to clipboard

Explicit db.flush() does not work when wal disabled in OptimisticTransactionDB

Open pragmaxim opened this issue 1 year ago • 2 comments

Expected behavior

db.flush should flush memtables to sst files. I use it in a shutdown hook so that I don't loose data as I am disabling WAL for performance reasons.

Actual behavior

it has no effect

Steps to reproduce the behavior

I posted this issue already https://github.com/rust-rocksdb/rust-rocksdb/issues/900 but then I figured it is probably a rocksdb issue.

pragmaxim avatar Aug 01 '24 13:08 pragmaxim

Can you repro it? I tried the following and it works fine.

TEST_P(OptimisticTransactionTest, Flush) {
  WriteOptions write_options;
  write_options.disableWAL = true;
  ASSERT_OK(txn_db->Put(write_options, Slice("foo"), Slice("bar")));
  ASSERT_OK(txn_db->Put(write_options, Slice("foo2"), Slice("bar")));
  ASSERT_OK(txn_db->Flush({}));
  std::vector<LiveFileMetaData> meta;
  txn_db->GetLiveFilesMetaData(&meta);
  ASSERT_EQ(meta.size(), 1);
}

cbi42 avatar Aug 02 '24 17:08 cbi42

@cbi42 I could probably repro it only in rust-lang, if you are interested. However it happens when one thread is still heavily committing new transactions while another thread calls db.flush ... I also tried to sleep 10 seconds after the flushing call but that did not help, literally nothing was flushed ...

Repro here : https://github.com/pragmaxim-com/rust-playground/commit/e5ec1c6956d8868a6e09257fc71fb40fada2bab4

pragmaxim avatar Aug 03 '24 17:08 pragmaxim