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

Use pthread_exit instead of exit to allow proper process shutdown. #535

Closed
szmyd opened this issue Sep 12, 2024 · 0 comments · Fixed by #536
Closed

Use pthread_exit instead of exit to allow proper process shutdown. #535

szmyd opened this issue Sep 12, 2024 · 0 comments · Fixed by #536

Comments

@szmyd
Copy link
Contributor

szmyd commented Sep 12, 2024

When NuRaft encounters an unrecoverable state it calls exit(2) directly, such as:

 // handle_commit.cxx
 160 bool raft_server::commit_in_bg_exec(size_t timeout_ms) {
 ...
 225         ptr<log_entry> le = log_store_->entry_at(index_to_commit);
 226         if (!le)
 227         {
 228             // LCOV_EXCL_START
 229             p_ft( "failed to get log entry with idx %" PRIu64 "", index_to_commit );
 230             ctx_->state_mgr_->system_exit(raft_err::N19_bad_log_idx_for_term);
 231             ::exit(-1);
 232             // LCOV_EXCL_STOP
 233         }

commit_bg_exec runs in a separate thread from the main process which could also have other threads or even other nuraft::raft_server's running. This forceful termination does not allow the process to try and enter a "non-random" state and behaves as if every thread abnormally terminated.

Requested is that pthread_exit(3) be used instead after a call to state_mgr::system_exit to announce that the server is going to stop processing. The main process can decide whether to also terminate and join all other threads normally, continue after abandoning this raft service or abend itself.

@szmyd szmyd changed the title Should use pthread_exit instead of exit to allow proper process shutdown. Use pthread_exit instead of exit to allow proper process shutdown. Sep 12, 2024
szmyd added a commit to szmyd/NuRaft that referenced this issue Sep 12, 2024
Allow the process to handle termination of raft service rather than
force process wide `exit()`

Addresses eBay#535
@szmyd szmyd linked a pull request Sep 12, 2024 that will close this issue
szmyd added a commit that referenced this issue Sep 18, 2024
* Use pthread_exit to terminate raft service.

Allow the process to handle termination of raft service rather than
force process wide `exit()`. This is compile time configurable during CMake configuration.

Addresses #535

---------

Co-authored-by: Jung-Sang Ahn <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant