Skip to content

Commit

Permalink
change the exit status of tgdblogutil-repair;
Browse files Browse the repository at this point in the history
avoid exit status 1 that is used by gflags
  • Loading branch information
ban-nobuhiro committed Apr 10, 2024
1 parent c6526c8 commit 59dcc72
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/tglogutil-repair-man.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Options:
* 0: No errors
* Repair process completed successfully
* Nothing was done because the contents were already healthy before processing
* 1: Error
* 16: Error
* Errors left unrepaired
* 64 or more: Unable to handle
* `dblogdir` does not exist
Expand Down
4 changes: 2 additions & 2 deletions docs/tglogutil_ja.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 永続化データディレクトリ管理ツール

* 2024-03-25 ban
* 2024-04-10 ban
* for 1.0.0-BETA4

## この文書について
Expand Down Expand Up @@ -51,7 +51,7 @@ $ tglogutil repair [options] <dblogdir>
リターンコード
* 0: 処理が正常終了
* もともと正常であったためなにも変更されなかった, あるいは 自動修復が正常終了.
* 1: 処理が異常終了
* 16: 処理が異常終了
* 自動修復できない破損に遭遇した.
* 64以上: 扱えないデータ形式であった.
* dblogdir が存在しない.
Expand Down
6 changes: 3 additions & 3 deletions src/limestone/dblogutil/dblogutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void inspect(dblog_scan &ds, std::optional<epoch_id_type> epoch) {
case dblog_scan::parse_error::broken_after_marked:
case dblog_scan::parse_error::nondurable_entries:
std::cout << "status: auto-repairable" << std::endl;
log_and_exit(1);
log_and_exit(1); // FIXME: conflicts with gflags error code
case dblog_scan::parse_error::unexpected:
std::cout << "status: unrepairable" << std::endl;
log_and_exit(2);
Expand Down Expand Up @@ -139,7 +139,7 @@ void repair(dblog_scan &ds, std::optional<epoch_id_type> epoch) {
case dblog_scan::parse_error::nondurable_entries:
case dblog_scan::parse_error::unexpected:
std::cout << "status: unrepairable" << std::endl;
log_and_exit(1);
log_and_exit(16);
case dblog_scan::parse_error::failed:
std::cout << "status: cannot-check" << std::endl;
log_and_exit(64);
Expand Down Expand Up @@ -193,7 +193,7 @@ int main(int argc, char *argv[]) { // NOLINT
auto usage = [&arg0]() {
//std::cout << "usage: " << arg0 << " {inspect | repair} [options] <dblogdir>" << std::endl;
std::cout << "usage: " << arg0 << " repair [options] <dblogdir>" << std::endl;
log_and_exit(100);
log_and_exit(1);
};
if (argc < 3) {
LOG(ERROR) << "missing parameters";
Expand Down
4 changes: 2 additions & 2 deletions test/limestone/utils/dblogutil_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ TEST_F(dblogutil_test, repairm_truncated_invalidated_epoch_header_detached) {
TEST_F(dblogutil_test, repairm_allzero) {
auto orig_data = data_allzero;
auto [rc, out] = repairm("pwal_0000", orig_data);
EXPECT_EQ(rc, 1 << 8);
EXPECT_EQ(rc, 16 << 8);
EXPECT_NE(out.find("\n" "status: unrepairable"), out.npos);
expect_no_change(orig_data);
}
Expand Down Expand Up @@ -442,7 +442,7 @@ TEST_F(dblogutil_test, repairc_truncated_invalidated_epoch_header) {
TEST_F(dblogutil_test, repairc_allzero) {
auto orig_data = data_allzero;
auto [rc, out] = repairc("pwal_0000", orig_data);
EXPECT_EQ(rc, 1 << 8);
EXPECT_EQ(rc, 16 << 8);
EXPECT_NE(out.find("\n" "status: unrepairable"), out.npos);
expect_no_change(orig_data);
}
Expand Down

0 comments on commit 59dcc72

Please sign in to comment.