Skip to content
Snippets Groups Projects
Commit 04e17d60 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

fix: race condition in on_shutdown

Tarantool remote requests are handled in a IProto thread, and
on_shutdown triggers are handled in the TX thread.

During shutdown we send a request to the leader, which introduces a race
condition in case we are the leader. If iproto thread shuts down before
the request is sent, it will never be handled.

The fix is simple: in case we are the leader during shutdown, don't send
the request, instead handle the request directly in the TX thread.
parent 69f89b4c
No related branches found
No related tags found
1 merge request!225fix: race condition in on_shutdown
Pipeline #10919 passed
......@@ -39,6 +39,12 @@ pub fn on_shutdown() {
node.wait_status();
continue;
});
if leader_id == raft_id {
if let Err(e) = node.handle_topology_request_and_wait(req.into()) {
crate::warn_or_panic!("failed to deactivate myself: {}", e);
}
break;
}
let leader = Storage::peer_by_raft_id(leader_id).unwrap().unwrap();
let wait_before_retry = Duration::from_millis(300);
let now = Instant::now();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment