From 3e7e199b36989ccd74d7b288b00032b16eb69761 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Mon, 17 Jul 2023 10:51:53 -0500 Subject: [PATCH] Handle shutdown exits in gen_statem:call/3 --- src/ra.hrl | 2 +- src/ra_server_proc.erl | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ra.hrl b/src/ra.hrl index 7d96f969..e706fc5a 100644 --- a/src/ra.hrl +++ b/src/ra.hrl @@ -65,7 +65,7 @@ -type consistent_query_ref() :: {From :: term(), Query :: ra:query_fun(), ConmmitIndex :: ra_index()}. --type safe_call_ret(T) :: timeout | {error, noproc | nodedown} | T. +-type safe_call_ret(T) :: timeout | {error, noproc | nodedown | shutdown} | T. -type states() :: leader | follower | candidate | await_condition. diff --git a/src/ra_server_proc.erl b/src/ra_server_proc.erl index 9b6eaa2b..e13ec1b8 100644 --- a/src/ra_server_proc.erl +++ b/src/ra_server_proc.erl @@ -1499,7 +1499,9 @@ gen_statem_safe_call(ServerId, Msg, Timeout) -> exit:{noproc, _} -> {error, noproc}; exit:{{nodedown, _}, _} -> - {error, nodedown} + {error, nodedown}; + exit:{shutdown, _} -> + {error, shutdown} end. do_state_query(all, State) -> State;