Skip to content
Snippets Groups Projects
Commit 6f29f9d7 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

iproto: introduce graceful shutdown protocol

This commit adds the graceful shutdown feature to the IPROTO protocol.
Net.box is patched by the next commit, which also adds tests.

Part of #5924

@TarantoolBot document
Title: Document IPROTO graceful shutdown

A new IPROTO request type was introduced - `IPROTO_SHUTDOWN`, code 77.
When asked to shut down (`os.exit()` is called or `SIGTERM` signal is
received), a server stops accepting new connections and sends a packet
of this type to each of its clients that support the graceful shutdown
feature (see below how a server figures out if a client supports the
feature). The server won't exit until all the clients that were sent the
packets close connections. If all the clients don't close connections
within the shutdown timeout, the server will exit anyway. The default
shutdown timeout is 3 seconds, and it can be configured with
`box.ctl.set_on_shutdown_timeout()`, which also determines the timeout
of `box.ctl.on_shutdown()` triggers.

An `IPROTO_SHUTDOWN` packet doesn't have any keys in its headers (not
even sync number or schema version) nor a body. A client isn't supposed
to reply to an `IPROTO_SHUTDOWN` packet. Instead it's supposed to close
its connection as soon as possible. A client may wait for pending
requests to complete and even send new requests after receiving an
`IPROTO_SHUTDOWN` packet. The server will serve them as usual until it
exits on timeout.

Clients that support the graceful shutdown feature are supposed to set
the `IPROTO_FEATURE_GRACEFUL_SHUTDOWN` feature (bit 4) when sending an
`IPROTO_ID` request to a server. Servers that support the feature set
the same bit in reply to an `IPROTO_ID` request. Introduction of this
feature bumped the IPROTO protocol version up to 4.
parent fbc25aae
No related branches found
No related tags found
Loading
Loading
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