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

fix(duplication): prevent plog files from being removed by GC while they are being checked by duplication #1597

Merged
merged 17 commits into from
Mar 28, 2024
Merged
4 changes: 4 additions & 0 deletions src/replica/duplication/load_from_private_log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ void load_from_private_log::run()

void load_from_private_log::find_log_file_to_start()
{
_duplicator->set_duplication_plog_checking(true);
empiredan marked this conversation as resolved.
Show resolved Hide resolved
empiredan marked this conversation as resolved.
Show resolved Hide resolved

// `file_map` has already excluded the useless log files during replica init.
auto file_map = _private_log->get_log_file_map();

Expand Down Expand Up @@ -166,6 +168,8 @@ void load_from_private_log::find_log_file_to_start(std::map<int, log_file_ptr> l
}
}
start_from_log_file(_current);

_duplicator->set_duplication_plog_checking(false);
}

void load_from_private_log::replay_log_block()
Expand Down
6 changes: 6 additions & 0 deletions src/replica/duplication/replica_duplicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,11 @@ uint64_t replica_duplicator::get_pending_mutations_count() const
return cnt > 0 ? static_cast<uint64_t>(cnt) : 0;
}

void replica_duplicator::set_duplication_plog_checking(bool checking)
{
_replica->set_duplication_plog_checking(checking);
}


} // namespace replication
} // namespace dsn
4 changes: 3 additions & 1 deletion src/replica/duplication/replica_duplicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ class replica_duplicator : public replica_base, public pipeline::base
// For metric "dup.pending_mutations_count"
uint64_t get_pending_mutations_count() const;

duplication_status::type status() const { return _status; };
duplication_status::type status() const { return _status; }

void set_duplication_plog_checking(bool checking);

private:
friend class duplication_test_base;
Expand Down
7 changes: 7 additions & 0 deletions src/replica/replica.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ class replica : public serverlet<replica>, public ref_counter, public replica_ba
replica_duplicator_manager *get_duplication_manager() const { return _duplication_mgr.get(); }
bool is_duplication_master() const { return _is_duplication_master; }
bool is_duplication_follower() const { return _is_duplication_follower; }
bool is_duplication_plog_checking() const { return _is_duplication_plog_checking.load(); }
void set_duplication_plog_checking(bool checking)
{
_is_duplication_plog_checking.store(checking);
}


//
// Backup
Expand Down Expand Up @@ -633,6 +639,7 @@ class replica : public serverlet<replica>, public ref_counter, public replica_ba
bool _is_manual_emergency_checkpointing{false};
bool _is_duplication_master{false};
bool _is_duplication_follower{false};
std::atomic<bool> _is_duplication_plog_checking{false};
acelyc111 marked this conversation as resolved.
Show resolved Hide resolved
acelyc111 marked this conversation as resolved.
Show resolved Hide resolved

// backup
std::unique_ptr<replica_backup_manager> _backup_mgr;
Expand Down
Loading