From 768aeab942fd503ee30f118451b75b148a00002f Mon Sep 17 00:00:00 2001 From: Matej Ferencevic Date: Mon, 4 Mar 2019 15:00:15 +0100 Subject: [PATCH] Add WAL recovery logging Reviewers: msantl Reviewed By: msantl Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1899 --- src/durability/single_node/recovery.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/durability/single_node/recovery.cpp b/src/durability/single_node/recovery.cpp index a9169d052..4e9e6d007 100644 --- a/src/durability/single_node/recovery.cpp +++ b/src/durability/single_node/recovery.cpp @@ -217,9 +217,10 @@ std::vector GetWalFiles(const fs::path &wal_dir) { return wal_files; } -bool ApplyOverDeltas( - const std::vector &wal_files, tx::TransactionId first_to_recover, - const std::function &f) { +bool ApplyOverDeltas(const std::vector &wal_files, + tx::TransactionId first_to_recover, + const std::function &f, + bool report_to_user) { for (auto &wal_file : wal_files) { auto wal_file_max_tx_id = TransactionIdFromWalFilename(wal_file.filename()); if (!wal_file_max_tx_id || *wal_file_max_tx_id < first_to_recover) continue; @@ -243,6 +244,8 @@ bool ApplyOverDeltas( if (!delta) break; f(*delta); } + + LOG_IF(INFO, report_to_user) << "Applied WAL deltas from: " << wal_file; } return true; @@ -263,12 +266,14 @@ std::vector ReadWalRecoverableTransactions( std::unordered_set committed_set; auto first_to_recover = FirstWalTxToRecover(recovery_data); ApplyOverDeltas( - wal_files, first_to_recover, [&](const database::StateDelta &delta) { + wal_files, first_to_recover, + [&](const database::StateDelta &delta) { if (delta.transaction_id >= first_to_recover && delta.type == database::StateDelta::Type::TRANSACTION_COMMIT) { committed_set.insert(delta.transaction_id); } - }); + }, + false); std::vector committed_tx_ids(committed_set.size()); for (auto id : committed_set) committed_tx_ids.push_back(id); @@ -446,7 +451,8 @@ void RecoverWal(const fs::path &durability_dir, database::GraphDb *db, default: transactions->Apply(delta); } - }); + }, + true); // TODO when implementing proper error handling return one of the following: // - WAL fully recovered