Skip to content

Commit bd7c227

Browse files
committed
Apply suggestions from code review
1 parent d11954f commit bd7c227

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

doc/dev_guide/internals/box_protocol.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,20 @@ Graceful shutdown protocol
10821082

10831083
Since :doc:`2.10.0 </release/2.10.0>`.
10841084

1085+
The graceful shutdown protocol is a mechanism that helps to prevent data loss in requests in case of a shutdown command.
1086+
According to the protocol, when a server receives an ``os.exit()`` command or a ``SIGTERM`` signal,
1087+
it does not exit immediately.
1088+
Instead of that, first, the server stops listening for new connections.
1089+
Then, the server sends the shutdown packets to all connections that support the graceful shutdown protocol.
1090+
When a client is notified about the upcoming server exit, it stops serving any new requests and
1091+
waits for active requests to complete before closing the connections.
1092+
Once all connections are terminated, the server will be shut down.
1093+
10851094
The protocol uses the event subscription system.
1086-
For more information about it, see :ref:`box.shutdown <system-events_box-shutdown>`
1087-
and :ref:`reference for the event watchers <box-watchers>`.
1095+
That is, the feature is available if a server supports :ref:`box.shutdown <system-events_box-shutdown>` event
1096+
and ``IPROTO_WATCH``.
1097+
For more information about it, see :ref:`reference for the event watchers <box-watchers>`
1098+
and the :ref:`corresponding section <box-protocol-watchers>` in Box Protocol.
10881099

10891100
The shutdown protocol works in the following way:
10901101

@@ -1095,7 +1106,7 @@ The shutdown protocol works in the following way:
10951106
The server broadcasts it to all subscribed remote watchers (see :ref:`IPROTO_WATCH <box_protocol-watch>`).
10961107
That is, the server calls :ref:`box.broadcast('box.shutdown', true) <box-broadcast>`
10971108
from the :ref:`box.ctl.on_shutdown() <box_ctl-on_shutdown>` trigger callback.
1098-
Once this is done, the server stops accepting new connections.
1109+
Once this is done, the server stops listening for new connections.
10991110

11001111
#. From now on, the server waits until all subscribed connections are terminated.
11011112

doc/reference/reference_lua/box_ctl/set_on_shutdown_timeout.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ box.ctl.set_on_shutdown_timeout()
1010

1111
Set a timeout for the :ref:`on_shutdown <box_ctl-on_shutdown>` trigger.
1212
If the timeout has expired, the server stops immediately
13-
regardless of whether there are any ``on_shutdown`` triggers left.
13+
regardless of whether any ``on_shutdown`` triggers are left unexecuted.
1414

1515
:param double timeout: time to wait for the trigger to be completed. The default value is 3 seconds.
1616

doc/reference/reference_lua/box_events/system_events.rst

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This triggers the ``box.info`` event, which states that the value of ``box.info.
2929
while ``box.info.uuid`` and ``box.info.cluster.uuid`` remain the same.
3030

3131
box.id
32-
~~~~~~
32+
------
3333

3434
Contains :ref:`identification <box_info_info>` of the instance.
3535
Value changes are rare.
@@ -53,7 +53,7 @@ Value changes are rare.
5353
}
5454
5555
box.status
56-
~~~~~~~~~~
56+
----------
5757

5858
Contains generic information about the instance status.
5959

@@ -70,7 +70,7 @@ Contains generic information about the instance status.
7070
}
7171
7272
box.election
73-
~~~~~~~~~~~~
73+
------------
7474

7575
Contains fields of :doc:`box.info.election </reference/reference_lua/box_info/election>`
7676
that are necessary to find out the most recent writable leader.
@@ -90,7 +90,7 @@ that are necessary to find out the most recent writable leader.
9090
}
9191
9292
box.schema
93-
~~~~~~~~~~
93+
----------
9494

9595
Contains schema-related data.
9696

@@ -105,14 +105,17 @@ Contains schema-related data.
105105
.. _system-events_box-shutdown:
106106

107107
box.shutdown
108-
~~~~~~~~~~~~
108+
------------
109109

110110
Contains a boolean value which indicates whether there is an active shutdown request.
111111

112112
The event is generated when the server receives a shutdown request (``os.exit()`` command or
113113
:ref:`SIGTERM <admin-server_signals>` signal).
114114

115-
The ``box.shutdown`` event is supposed to be used with connectors.
115+
The ``box.shutdown`` event is applied for the graceful shutdown protocol.
116+
It is a feature which is available since :doc:`2.10.0 </release/2.10.0>`.
117+
This protocol is supposed to be used with connectors to signal a client about the upcoming server shutdown and
118+
close active connections without broken requests.
116119
For more information, refer to the :ref:`graceful shutdown protocol <box-protocol-shutdown>` section.
117120

118121
Usage example

doc/reference/reference_lua/net_box.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Most ``net.box`` methods accept the last ``{options}`` argument, which can be:
5656
The default value is ``false``.
5757
For an example, see option description :ref:`below <net_box-return_raw>`.
5858

59+
.. _net_box-state_diagram:
60+
5961
The diagram below shows possible connection states and transitions:
6062

6163
.. ifconfig:: builder not in ('latex', )
@@ -836,10 +838,10 @@ With the ``net.box`` module, you can use the following
836838

837839
The trigger starts in a new fiber.
838840
While the ``on_shutdown()`` trigger is running, the connection stays active.
839-
It means that it is allowed to send new requests from a trigger callback.
841+
It means that the trigger callback is allowed to send new requests.
840842

841843
After the trigger return, the ``net.box`` connection goes to the ``graceful_shutdown`` state
842-
(check :ref:`the state diagram <net_box-options>` for details).
844+
(check :ref:`the state diagram <net_box-state_diagram>` for details).
843845
In this state, no new requests are allowed.
844846
The connection waits for all pending requests to be completed.
845847

0 commit comments

Comments
 (0)