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

cleanup procedure change: flush persistent data on leave #263

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 8 additions & 4 deletions include/derecho/core/detail/group_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,11 @@ Group<ReplicatedTypes...>::Group(const SubgroupInfo& subgroup_info, Factory<Repl

template <typename... ReplicatedTypes>
Group<ReplicatedTypes...>::~Group() {
// shutdown the persistence manager
// TODO-discussion:
// Will a node be able to come back once it leaves? if not, maybe we should
// shut it down on leave().
/**
We shut down the persistence_manager on leave, assuming a process will not come back once it leaves.
Here we shut it down again, in case the process is just leaving by itself instead of a system-level
shutdown. Please note that the shutdown opeartion is idempotent.
*/
persistence_manager.shutdown(true);
}

Expand Down Expand Up @@ -531,6 +532,9 @@ void Group<ReplicatedTypes...>::leave(bool group_shutdown) {
if(group_shutdown) {
view_manager.silence();
view_manager.barrier_sync();
/* Here we flush the data to persistent store and wait until it finished. */
persistence_manager.shutdown(true);
view_manager.barrier_sync();
}
view_manager.leave();
}
Expand Down
7 changes: 6 additions & 1 deletion src/core/persistence_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ PersistenceManager::PersistenceManager(
}

PersistenceManager::~PersistenceManager() {
if (this->persist_thread.joinable()) {
this->persist_thread.join();
}
sem_destroy(&persistence_request_sem);
}

Expand Down Expand Up @@ -233,7 +236,9 @@ void PersistenceManager::shutdown(bool wait) {
sem_post(&persistence_request_sem); // kick the persistence thread in case it is sleeping

if(wait) {
this->persist_thread.join();
if (this->persist_thread.joinable()) {
this->persist_thread.join();
}
}
}
} // namespace derecho