Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PageStorage: Fix the WAL snapshot dumped into file may contains invalid "being_ref_count" #4987

Merged
merged 19 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update comment
  • Loading branch information
JaySon-Huang committed May 24, 2022
commit 1e3bea55569535a9c0edaf940c107ca0b7a41c8e
2 changes: 1 addition & 1 deletion dbms/src/Storages/Page/PageStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class PageStorage : private boost::noncopyable
SettingUInt64 blob_block_alignment_bytes = 0;

SettingUInt64 wal_roll_size = PAGE_META_ROLL_SIZE;
SettingUInt64 wal_recover_mode = 0x00;
SettingUInt64 wal_recover_mode = 0x00; // WALRecoveryMode::TolerateCorruptedTailRecords
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply

Suggested change
SettingUInt64 wal_recover_mode = 0x00; // WALRecoveryMode::TolerateCorruptedTailRecords
SettingUInt64 wal_recover_mode = WALRecoveryMode::TolerateCorruptedTailRecords;

SettingUInt64 wal_max_persisted_log_files = MAX_PERSISTED_LOG_FILES;

void reload(const Config & rhs)
Expand Down
5 changes: 4 additions & 1 deletion dbms/src/Storages/Page/V3/PageDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,10 @@ bool PageDirectory::tryDumpSnapshot(const ReadLimiterPtr & read_limiter, const W
auto files_snap = wal->getFilesSnapshot();
if (files_snap.needSave(max_persisted_log_files))
{
// Read from `file_snap` to create an edit for snapshot.
// To prevent writes from affecting dumping snapshot (and vice versa), old log files
// are read from disk and a temporary PageDirectory is generated for dumping snapshot.
// The main reason write affect dumping snapshot is that we can not get a read-only
// `being_ref_count` by the function `createSnapshot()`.
assert(!files_snap.persisted_log_files.empty()); // should not be empty when `needSave` return true
auto log_num = files_snap.persisted_log_files.rbegin()->log_num;
auto identifier = fmt::format("{}_dump_{}", wal->name(), log_num);
Expand Down
14 changes: 6 additions & 8 deletions dbms/src/Storages/Page/V3/WALStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,19 @@ class WALStore
public:
void setRecoverMode(UInt64 recover_mode)
{
if (recover_mode != static_cast<UInt64>(WALRecoveryMode::TolerateCorruptedTailRecords)
&& recover_mode != static_cast<UInt64>(WALRecoveryMode::AbsoluteConsistency)
&& recover_mode != static_cast<UInt64>(WALRecoveryMode::PointInTimeRecovery)
&& recover_mode != static_cast<UInt64>(WALRecoveryMode::SkipAnyCorruptedRecords))
if (unlikely(recover_mode != static_cast<UInt64>(WALRecoveryMode::TolerateCorruptedTailRecords)
&& recover_mode != static_cast<UInt64>(WALRecoveryMode::AbsoluteConsistency)
&& recover_mode != static_cast<UInt64>(WALRecoveryMode::PointInTimeRecovery)
&& recover_mode != static_cast<UInt64>(WALRecoveryMode::SkipAnyCorruptedRecords)))
{
throw Exception("Unknow recover mode [num={}]", recover_mode);
}
wal_recover_mode = recover_mode;
}

static WALRecoveryMode getRecoverMode()
WALRecoveryMode getRecoverMode()
{
// return static_cast<WALRecoveryMode>(wal_recover_mode.get());
// Now we only use this mode
return WALRecoveryMode::TolerateCorruptedTailRecords;
return static_cast<WALRecoveryMode>(wal_recover_mode.get());
}
};

Expand Down