@@ -58,10 +58,14 @@ module wal_manager;
58
58
59
59
namespace infinity {
60
60
61
- WalManager::WalManager (Storage *storage, String wal_dir, u64 wal_size_threshold, u64 delta_checkpoint_interval_wal_bytes, FlushOptionType flush_option)
61
+ WalManager::WalManager (Storage *storage,
62
+ String wal_dir,
63
+ u64 wal_size_threshold,
64
+ u64 delta_checkpoint_interval_wal_bytes,
65
+ FlushOptionType flush_option)
62
66
: cfg_wal_size_threshold_(wal_size_threshold), cfg_delta_checkpoint_interval_wal_bytes_(delta_checkpoint_interval_wal_bytes), wal_dir_(wal_dir),
63
67
wal_path_ (wal_dir + " /" + WalFile::TempWalFilename()), storage_(storage), running_(false ), flush_option_(flush_option), last_ckp_wal_size_(0 ),
64
- checkpoint_in_progress_(false ), last_ckp_ts_(UNCOMMIT_TS ), last_full_ckp_ts_(UNCOMMIT_TS ) {}
68
+ checkpoint_in_progress_(false ), last_ckp_ts_(0 ), last_full_ckp_ts_(0 ) {}
65
69
66
70
WalManager::~WalManager () {
67
71
if (running_.load ()) {
@@ -142,6 +146,8 @@ i64 WalManager::WalSize() const {
142
146
return wal_size_;
143
147
}
144
148
149
+ TxnTimeStamp WalManager::GetLastCkpTS () { return last_ckp_ts_; }
150
+
145
151
// Flush is scheduled regularly. It collects a batch of transactions, sync
146
152
// wal and do parallel committing. Each sync cost ~1s. Each checkpoint cost
147
153
// ~10s. So it's necessary to sync for a batch of transactions, and to
@@ -274,25 +280,26 @@ void WalManager::Checkpoint(ForceCheckpointTask *ckp_task, TxnTimeStamp max_comm
274
280
void WalManager::CheckpointInner (bool is_full_checkpoint, Txn *txn, TxnTimeStamp max_commit_ts, i64 wal_size) {
275
281
DeferFn defer ([&] { checkpoint_in_progress_.store (false ); });
276
282
283
+ TxnTimeStamp last_ckp_ts = GetLastCkpTS ();
277
284
if (is_full_checkpoint) {
278
285
if (max_commit_ts == last_full_ckp_ts_) {
279
286
LOG_INFO (fmt::format (" Skip full checkpoint because the max_commit_ts {} is the same as the last full checkpoint" , max_commit_ts));
280
287
return ;
281
288
}
282
- if (last_full_ckp_ts_ != UNCOMMIT_TS && last_full_ckp_ts_ >= max_commit_ts) {
289
+ if (last_full_ckp_ts_ >= max_commit_ts) {
283
290
UnrecoverableError (
284
291
fmt::format (" WalManager::UpdateLastFullMaxCommitTS last_full_ckp_ts_ {} >= max_commit_ts {}" , last_full_ckp_ts_, max_commit_ts));
285
292
}
286
- if (last_ckp_ts_ != UNCOMMIT_TS && last_ckp_ts_ > max_commit_ts) {
287
- UnrecoverableError (fmt::format (" WalManager::UpdateLastFullMaxCommitTS last_ckp_ts_ {} >= max_commit_ts {}" , last_ckp_ts_ , max_commit_ts));
293
+ if (last_ckp_ts > max_commit_ts) {
294
+ UnrecoverableError (fmt::format (" WalManager::UpdateLastFullMaxCommitTS last_ckp_ts {} >= max_commit_ts {}" , last_ckp_ts , max_commit_ts));
288
295
}
289
296
} else {
290
- if (max_commit_ts == last_ckp_ts_ ) {
297
+ if (max_commit_ts == last_ckp_ts ) {
291
298
LOG_INFO (fmt::format (" Skip delta checkpoint because the max_commit_ts {} is the same as the last checkpoint" , max_commit_ts));
292
299
return ;
293
300
}
294
- if (last_ckp_ts_ >= max_commit_ts) {
295
- UnrecoverableError (fmt::format (" WalManager::UpdateLastMaxCommitTS last_ckp_ts_ {} >= max_commit_ts {}" , last_ckp_ts_ , max_commit_ts));
301
+ if (last_ckp_ts >= max_commit_ts) {
302
+ UnrecoverableError (fmt::format (" WalManager::UpdateLastMaxCommitTS last_ckp_ts {} >= max_commit_ts {}" , last_ckp_ts , max_commit_ts));
296
303
}
297
304
}
298
305
try {
0 commit comments