Skip to content

Commit

Permalink
[#14009] docdb: fix disable_checksums option in yb_backup
Browse files Browse the repository at this point in the history
Summary:
c8ce4bd seems to have broken the `--disable_checksums`
option of `yb_backup.py`.  There's an assert in `create_checksum_cmd_not_quoted` that checks that
`self.use_xxhash_checksum` is not `None`. This function is unconditionally called in
`prepare_download_command`. However we do not set `self.use_xxhash_checksum` under all circumstances
when `disable_checksums` is `True`.

Test Plan: Added test.

Reviewers: skedia, oleg, msun

Reviewed By: msun

Subscribers: jenkins-bot, yugaware, slingam, ybase, bogdan

Differential Revision: https://phabricator.dev.yugabyte.com/D19540
  • Loading branch information
druzac committed Sep 19, 2022
1 parent cf16167 commit baa31bf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ent/src/yb/tools/yb-backup-test_ent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2456,5 +2456,34 @@ TEST_F(YBBackupTest, YB_DISABLE_TEST_IN_SANITIZERS_OR_MAC(TestColocationDuplicat
LOG(INFO) << "Test finished: " << CURRENT_TEST_CASE_AND_TEST_NAME_STR();
}

TEST_F(YBBackupTest, YB_DISABLE_TEST_IN_SANITIZERS_OR_MAC(TestBackupChecksumsDisabled)) {
ASSERT_NO_FATALS(CreateTable("CREATE TABLE mytbl (k INT PRIMARY KEY, v TEXT)"));
ASSERT_NO_FATALS(InsertOneRow("INSERT INTO mytbl (k, v) VALUES (100, 'foo')"));
ASSERT_NO_FATALS(InsertOneRow("INSERT INTO mytbl (k, v) VALUES (101, 'bar')"));
ASSERT_NO_FATALS(InsertOneRow("INSERT INTO mytbl (k, v) VALUES (102, 'cab')"));

const string backup_dir = GetTempDir("backup");
ASSERT_OK(RunBackupCommand(
{"--backup_location", backup_dir, "--keyspace", "ysql.yugabyte", "--disable_checksums",
"create"}));
ASSERT_NO_FATALS(InsertOneRow("INSERT INTO mytbl (k, v) VALUES (999, 'foo')"));
ASSERT_OK(RunBackupCommand(
{"--backup_location", backup_dir, "--keyspace", "ysql.yugabyte_new", "--disable_checksums",
"restore"}));

SetDbName("yugabyte_new"); // Connecting to the second DB from the moment.
ASSERT_NO_FATALS(RunPsqlCommand(
"SELECT k, v FROM mytbl ORDER BY k",
R"#(
k | v
-----+-----
100 | foo
101 | bar
102 | cab
(3 rows)
)#"));
LOG(INFO) << "Test finished: " << CURRENT_TEST_CASE_AND_TEST_NAME_STR();
}

} // namespace tools
} // namespace yb
3 changes: 3 additions & 0 deletions managed/devops/bin/yb_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,9 @@ def post_process_arguments(self):
XXH64HASH_TOOL_PATH = '/usr/bin/xxhsum'
SHA_TOOL_PATH = '/usr/bin/shasum'

if self.args.disable_checksums:
self.use_xxhash_checksum = False

def table_names_str(self, delimeter='.', space=' '):
return get_table_names_str(self.args.keyspace, self.args.table, delimeter, space)

Expand Down

0 comments on commit baa31bf

Please sign in to comment.