Skip to content

Commit

Permalink
tglogutil-compaction: add option --dry-run
Browse files Browse the repository at this point in the history
  • Loading branch information
ban-nobuhiro committed Jun 27, 2024
1 parent 171523a commit efcd019
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/tglogutil-compaction-man.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Specify the location set in the `log_location` parameter in the `[datastore]` se
Options:
* `--force=<bool>`
* If `true`, do not prompt before processing (default `false`)
* `--dry-run=<bool>`
* Dry run mode. If `true`, transaction log files are not modified (default `false`)
* `--thread-num=<number>`
* Number (default `1`) of concurrent processing thread of reading log files
* `--working-dir=</path/to/working-dir>`
Expand Down
8 changes: 8 additions & 0 deletions src/limestone/dblogutil/dblogutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ DEFINE_string(output_format, "human-readable", "format of output (human-readable

// compaction
DEFINE_bool(force, false, "(subcommand compaction) skip start prompt");
DEFINE_bool(dry_run, false, "(subcommand compaction) dry run");
DEFINE_string(working_dir, "", "(subcommand compaction) working directory");
DEFINE_bool(make_backup, false, "(subcommand compaction) make backup of target dblogdir");

Expand Down Expand Up @@ -240,6 +241,13 @@ void compaction(dblog_scan &ds, std::optional<epoch_id_type> epoch) {
throw std::runtime_error("I/O error");
}

if (FLAGS_dry_run) {
std::cout << "compaction will be successfully completed (dry-run mode)" << std::endl;
VLOG_LP(log_info) << "deleting work directory " << tmp;
boost::filesystem::remove_all(tmp);
return;
}

if (FLAGS_make_backup) {
auto bkdir = make_backup_dir_next_to(from_dir);
VLOG_LP(log_info) << "renaming " << from_dir << " to " << bkdir << " for backup";
Expand Down

0 comments on commit efcd019

Please sign in to comment.