rabbitmq / ra

A Raft implementation for Erlang and Elixir that strives to be efficient and make it easier to use multiple Raft clusters in a single system.
Other
813 stars 96 forks source link

Handle shutdown exits in gen_statem:call/3 #388

Closed the-mikedavis closed 1 year ago

the-mikedavis commented 1 year ago

Proposed Changes

gen_statem:call/3 can fail if the server shuts down before replying to the call, exiting with {shutdown, Location}. We can handle this exit like the other exits in the gen_statem_safe_call/3. I think it makes sense to return {error, noproc} in this case since it's effectively the same as the server not being alive, but I think an {error, shutdown} return could be ok as well.

Types of Changes

What types of changes does your code introduce to this project? Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask on the mailing list. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

michaelklishin commented 1 year ago

I like the shutdown one better. noproc more or less never means an intended return value, or at least some people automatically expect it to indicate an unhandled error. WDYT?

the-mikedavis commented 1 year ago

Yeah that sounds good to me. noproc is also a little different than shutdown here since the server did actually receive the command with shutdown, so let's go with shutdown.