-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document graceful shutdown of net.box connections #2633
Comments
Related issue: #2632 |
Hold on! We are currently thinking about reworking the feature implementation, see tarantool/tarantool#6813. I'll update the ticket once we agree how to proceed. |
tarantool/tarantool#6813 was merged. It reworked the graceful shutdown protocol using watch/event. The updated description is below (I can't update the issue description). In Tarantool 2.10.0-beta2-78-g2e9cbec3091e a new system event was introduced, 'box.shutdown'. A server generates this event with the value equal to
The timeout is configured with The graceful shutdown protocol is implemented by the net.box connector as follows:
If the server doesn't support the new 'box.shutdown' event (or doesn't support Don't forget to update the net.box state machine diagram on this page:
|
Fixes #2633 * Add ``box.shutdown`` event, ``box_ctl-on_shutdown_timeout`` function, and net.box method * Add diagram * Update .po files
Related dev. PR: tarantool/tarantool#6813
Product: Tarantool
Since: 2.10
Audience/target: developers
Root document:
https://www.tarantool.io/en/doc/latest/reference/reference_lua/net_box/
https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_ctl/
https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_events/ (when it appears, after #2407)
https://www.tarantool.io/en/doc/latest/dev_guide/internals/box_protocol/ (check after #2408 if anything is to be added)
SME: @ locker
Details
In Tarantool 2.10.0-beta2-78-g2e9cbec3091e, a new system event was introduced, 'box.shutdown'. A server generates this event with the value equal to
true
when it's asked to exit (os.exit()
is called or SIGTERM signal is received). (Essentially, a server simply callsbox.broadcast('box.shutdown', true)
from abox.ctl.on_shutdown()
trigger callback.) As any other event, 'box.shutdown' is broadcasted to all remote watchers subscribed to it (seeIPROTO_WATCH
). The event is supposed to be used by connectors to implement the graceful shutdown protocol:os.exit()
or SIGTERM).true
.true
.The timeout is configured with
box.ctl.set_on_shutdown_timeout()
. It's set to 3 seconds by default.The graceful shutdown protocol is implemented by the net.box connector as follows:
true
, a net.box connection invokes user-defined triggers installed with the new connection method,on_shutdown()
. Theon_shutdown()
method has the same API as any other connection method used for installing triggers, for example,on_disconnect()
.on_shutdown()
triggers are invoked from a new fiber. Whileon_shutdown()
triggers are running, the connection remains active. This means that it's allowed to send new requests from a trigger callback.on_shutdown()
triggers return, the net.box connection switches to the newgraceful_shutdown
state. In this state, no new requests are allowed.error
orerror_reconnect
state, depending on whetherreconnect_after
connection option is set, with the error message set to "Peer closed", just like it used to without the newgraceful_shutdown
state, when the server immediately closed the connection on shutdown.If the server doesn't support the new 'box.shutdown' event (or doesn't support
IPROTO_WATCH
),on_shutdown()
triggers will never be executed and the connection will be abruptly closed by the server.Don't forget to update the net.box state machine diagram on this page:
Definition of done
Do this issue after the following:
Document box.watch and box.broadcast
Document IPROTO watchers
The text was updated successfully, but these errors were encountered: