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.
Showing
- src/box/iproto.cc 89 additions, 3 deletionssrc/box/iproto.cc
- src/box/iproto_constants.h 11 additions, 0 deletionssrc/box/iproto_constants.h
- src/box/iproto_features.c 2 additions, 0 deletionssrc/box/iproto_features.c
- src/box/iproto_features.h 10 additions, 1 deletionsrc/box/iproto_features.h
- src/box/lua/net_box.lua 1 addition, 0 deletionssrc/box/lua/net_box.lua
- src/box/xrow.c 31 additions, 0 deletionssrc/box/xrow.c
- src/box/xrow.h 7 additions, 0 deletionssrc/box/xrow.h
- src/lib/core/evio.c 4 additions, 0 deletionssrc/lib/core/evio.c
- test/box-py/iproto.result 2 additions, 2 deletionstest/box-py/iproto.result
- test/box/net.box_iproto_id.result 8 additions, 3 deletionstest/box/net.box_iproto_id.result
Loading