diff --git a/docs/tglogutil-compaction-man.md b/docs/tglogutil-compaction-man.md index 5c733c69..b1b6968b 100644 --- a/docs/tglogutil-compaction-man.md +++ b/docs/tglogutil-compaction-man.md @@ -16,6 +16,8 @@ Specify the location set in the `log_location` parameter in the `[datastore]` se Options: * `--force=` * If `true`, do not prompt before processing (default `false`) +* `--dry-run=` + * Dry run mode. If `true`, transaction log files are not modified (default `false`) * `--thread-num=` * Number (default `1`) of concurrent processing thread of reading log files * `--working-dir=` diff --git a/src/limestone/dblogutil/dblogutil.cpp b/src/limestone/dblogutil/dblogutil.cpp index 619a6f14..dab72eb6 100644 --- a/src/limestone/dblogutil/dblogutil.cpp +++ b/src/limestone/dblogutil/dblogutil.cpp @@ -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"); @@ -240,6 +241,13 @@ void compaction(dblog_scan &ds, std::optional 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";