Skip to content

Commit

Permalink
dbg
Browse files Browse the repository at this point in the history
  • Loading branch information
hx235 committed Dec 25, 2024
1 parent e241420 commit d566546
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions db/db_wal_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1865,19 +1865,18 @@ TEST_F(DBWALTest, TrackAndVerifyWALsRecycleWAL) {

// Recycle the first WAL
ASSERT_OK(Put("key1", "old_value"));
// Recycle the second WAL
ASSERT_OK(dbfull()->TEST_SwitchWAL());
ASSERT_OK(Put("key1", "new_value"));

// Create WAL hole
VectorWalPtr log_files;
ASSERT_OK(db_->GetSortedWalFiles(log_files));
ASSERT_GE(log_files.size(), 1);
ASSERT_GE(log_files.size(), 2);
ASSERT_OK(test::TruncateFile(
options.env, LogFileName(dbname_, log_files.back()->LogNumber()),
options.env, LogFileName(dbname_, log_files.front()->LogNumber()),
0 /* new_length */));

// Recycle the second WAL
ASSERT_OK(dbfull()->TEST_SwitchWAL());
ASSERT_OK(Put("key1", "new_value"));

Status s = TryReopen(options);

ASSERT_OK(s);
Expand Down Expand Up @@ -1919,18 +1918,18 @@ TEST_P(DBWALTrackAndVerifyWALsWithParamsTest, Basic) {
&sleeping_task, Env::Priority::HIGH);

ASSERT_OK(Put("key1", "old_value"));
ASSERT_OK(dbfull()->TEST_SwitchWAL());
ASSERT_OK(Put("key1", "new_value"));

// Create WAL hole
VectorWalPtr log_files;
ASSERT_OK(db_->GetSortedWalFiles(log_files));
ASSERT_EQ(log_files.size(), 1);
ASSERT_EQ(log_files.size(), 2);
// Drop `Put("key1", "old_value")` in WAL
ASSERT_OK(test::TruncateFile(
options.env, LogFileName(dbname_, log_files.back()->LogNumber()),
options.env, LogFileName(dbname_, log_files.front()->LogNumber()),
0 /* new_length */));

ASSERT_OK(dbfull()->TEST_SwitchWAL());
ASSERT_OK(Put("key1", "new_value"));

Status s = TryReopen(options);
if (options.wal_recovery_mode == WALRecoveryMode::kPointInTimeRecovery) {
ASSERT_OK(s);
Expand Down

0 comments on commit d566546

Please sign in to comment.