Skip to content

Commit

Permalink
fix initial epoch value after recovering
Browse files Browse the repository at this point in the history
  • Loading branch information
ban-nobuhiro committed Jan 24, 2024
1 parent 4d4d0ac commit 56c0e0e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/limestone/datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ void datastore::switch_epoch(epoch_id_type new_epoch_id) {
check_after_ready(static_cast<const char*>(__func__));

auto neid = static_cast<std::uint64_t>(new_epoch_id);
if (neid <= epoch_id_switched_.load()) {
LOG_LP(WARNING) << "switch to epoch_id_type of " << neid << " is curious";
if (auto switched = epoch_id_switched_.load(); neid <= switched) {
LOG_LP(WARNING) << "switch to epoch_id_type of " << neid << " (<=" << switched << ") is curious";
}

epoch_id_switched_.store(neid);
Expand Down
5 changes: 3 additions & 2 deletions src/limestone/datastore_snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ void datastore::create_snapshot() {
#endif

epoch_id_type ld_epoch = last_durable_epoch_in_dir();
epoch_id_switched_.store(ld_epoch + 1); // ??

[[maybe_unused]]
auto insert_entry_or_update_to_max = [&sortdb](log_entry& e){
Expand Down Expand Up @@ -272,7 +271,9 @@ void datastore::create_snapshot() {
}
auto is_wal = [](const boost::filesystem::path& p){ return p.filename().string().substr(0, log_channel::prefix.length()) == log_channel::prefix; };
epoch_id_type max_appeared_epoch = scan_pwal_files_in_dir(from_dir, num_worker, is_wal, ld_epoch, add_entry);
epoch_id_informed_.store(max_appeared_epoch);
// epoch +1 for margin (probably unnecessary)
epoch_id_switched_.store(max_appeared_epoch + 1);
epoch_id_informed_.store(max_appeared_epoch + 1);

boost::filesystem::path sub_dir = location_ / boost::filesystem::path(std::string(snapshot::subdirectory_name_));
boost::system::error_code error;
Expand Down

0 comments on commit 56c0e0e

Please sign in to comment.