Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WAL files are not deleted when only empty transaction are committed #12958

Open
marcsanfacon opened this issue Aug 22, 2024 · 0 comments
Open

Comments

@marcsanfacon
Copy link

We are leveraging RocksDB and are leveraging the transaction mechanism to sync with other structures. We encountered a behavior where there would be thousands of LOG files in the main directory of the database.

By trying to reproduce on a small scale, we discovered that empty transactions seems to be the cause of this. Our system do frequent commits and it happens that no operations were done in part of the systems, but other parts are required to commit.

We tried playing with WAL_ttl_seconds but were not able to reproduce the behavior. If we add a simple Put to the database, then the LOG files are properly deleted once they are no longer required.

Expected behavior

LOG files should be cleaned-up once they are no longer required.

Actual behavior

LOG files accumulate when empty transactions are committed.

Steps to reproduce the behavior

rocksdb::TransactionDB* txnDb{nullptr};
rocksdb::TransactionDBOptions txnDbOpts;
rocksdb::Options options;
options.create_if_missing = true;
txnDbOpts.write_policy = rocksdb::TxnDBWritePolicy::WRITE_PREPARED;

for (int i = 0; i < 10; ++i) {
  auto status = rocksdb::TransactionDB::Open(options, txnDbOpts, "/tmp/rdbtest", &txnDb);
  assert(status.ok());
  rocksdb::WriteOptions wrtOpts{};
  rocksdb::TransactionOptions txnOpts{};

  trn->Prepare();
  trn->Commit();
  delete trn;

  rocksdb::FlushOptions fopt;
  fopt.wait = true;
  status = txnDb->Flush(fopt);
  assert(status.ok());

  rocksdb::CancelAllBackgroundWork(txnDb, true);
  status = txnDb->Close();
  assert(status.ok());
  delete txnDb;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant