The wal_dir suffers from a bad option path after finishing checkpoint
- Dominant language
- C++
- Stars
- 32.1k
- Forks
- 6.9k
- Avg merge
- 32m
- Merged PRs (30d)
- 1
Description
### Expected behavior
If wal_dir specified, the wal_dir in option file generated by checkpoint should point to checkpoint dir.
### Actual behavior
The wal_dir in option file generated by checkpoint points to the old wal path.
### Steps to reproduce the behavior
Take a look at the following example:
```
#include
#include
#include
#include
#include "rocksdb/db.h"
#include "rocksdb/slice.h"
#include "rocksdb/options.h"
#include "rocksdb/utilities/checkpoint.h"
using namespace rocksdb;
std::string kDBPath = "./db";
int main() {
Options options;
options.create_if_missing = true;
DB* db;
Status s = DB::Open(options, kDBPath, &db);
assert(s.ok());
ColumnFamilyHandle* cf;
s = db->CreateColumnFamily(ColumnFamilyOptions(), "new_cf", &cf);
assert(s.ok());
delete cf;
delete db;
std::vector column_families;
column_families.push_back(ColumnFamilyDescriptor(
kDefaultColumnFamilyName, ColumnFamilyOptions()));
column_families.push_back(ColumnFamilyDescriptor(
"new_cf", ColumnFamilyOptions()));
std::vector handles;
DBOptions db_options;
db_options.wal_dir = kDBPath + "_wal";
s = DB::Open(db_options, kDBPath, column_families, &handles, &db);
assert(s.ok());
s = db->Put(WriteOptions(), handles[1], Slice("key"), Slice("value"));
assert(s.ok());
std::string value;
s = db->Get(ReadOptions(), handles[1], Slice("key"), &value);
assert(s.ok());
// atomic write
WriteBatch batch;
batch.Put(handles[0], Slice("key2"), Slice("value2"));
batch.Put(handles[1], Slice("key3"), Slice("value3"));
batch.Delete(handles[0], Slice("key"));
s = db->Write(WriteOptions(), &batch);
assert(s.ok());
Checkpoint* checkpoint = nullptr;
s = Checkpoint::Create(db, &checkpoint);
assert(s.ok());
std::unique_ptr checkpoint_guard(checkpoint);
std::string snapshot_name = kDBPath + "_ck";
s = checkpoint->CreateCheckpoint(snapshot_name, std::numeric_limits::max());
assert(s.ok());
for (auto handle : handles) {
delete handle;
}
delete db;
return 0;
}
```
The directory structure is shown below after the example executed.
```
├── db
│ ├── 000005.log
│ ├── CURRENT
│ ├── IDENTITY
│ ├── LOCK
│ ├── LOG
│ ├── LOG.old.1628671900840290
│ ├── MANIFEST-000010
│ ├── OPTIONS-000009
│ └── OPTIONS-000013
├── db_ck
│ ├── 000011.log
│ ├── CURRENT
│ ├── MANIFEST-000010
│ └── OPTIONS-000013
├── db_wal
│ └── 000011.log
```
The wal_dir in db_ck/OPTIONS-000013 points to ./db_wal
Contributor guide
Assessment
This issue has not been assessed yet.