Skip to content

Commit 9131155

Browse files
committed
Apply review suggestions
1 parent 6e0a20e commit 9131155

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

doc/platform/sharding/vshard_admin.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ When such an operation is applied again, the value for the field increases by 2
563563

564564
.. note::
565565

566-
Any write requests that are intended to be executed repeatedly should be idempotent.
566+
Any write requests that are intended to be executed repeatedly (for example, retried after an error) should be idempotent.
567567
The operations' idempotency ensures that the change is applied **only once**.
568568

569569
A request may need to be run again if an error occurs on the server or client side.
@@ -588,17 +588,26 @@ In this case:
588588
Lack of such a check might lead to duplicate records or unplanned data changes.
589589

590590
For example, a client has sent a request to the server. The client is waiting for a response within a specified timeout.
591-
If the server sends a successful response after this time has elapsed, the client will receive an error.
591+
If the server sends a successful response after this time has elapsed,
592+
the client won't see this response due to a timeout, and will consider the request as failed.
592593
When re-executing this request without additional check, the operation may be applied twice.
593594

594-
A write request can be executed repeatedly without a check only if the error occurred on the server side --
595-
for example, `ER_READONLY`.
595+
A write request can be executed repeatedly without a check in two cases:
596+
- The request is idempotent.
597+
- It's known for sure that the previous request raised an error before executing any write operations.
598+
For example, ER_READONLY was thrown by the server.
599+
In this case, we know that the request couldn't complete due to server in read-only mode.
596600

597601
**Deduplication examples**
598602

599603
To ensure that the write requests (INSERT, UPDATE, UPSERT, and autoincrement) are idempotent,
600604
you should implement a check that the request is applied for the first time.
601605

606+
.. note::
607+
608+
There is no built-in deduplication check in Tarantool.
609+
Currently, deduplication can be only implemented by the user in the application code.
610+
602611
For example, when you add a new tuple to a space, you can use a unique insert ID to check the request.
603612
In the example below within a single transaction:
604613

doc/reference/reference_rock/vshard/vshard_router.rst

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ Router public API
132132
* ``timeout`` — a request timeout, in seconds. If the ``router`` cannot identify a
133133
shard with the specified ``bucket_id``, it will retry until the timeout is reached.
134134

135+
* ``request_timeout`` (since ``vshard`` 0.1.28) — timeout in seconds that serves as a protection against hung replicas.
136+
The parameter is used in the read requests only (``mode=read``).
137+
It is necessary to pass the ``request_timeout`` and ``timeout`` parameters together, with the following requirement:
138+
``timeout > request_timeout``.
139+
140+
The ``timeout`` parameter controls how much time a single request attempt may take.
141+
When this time is over (the ``TimedOut`` error is raised), router retries the request on the next replica as long
142+
as the ``timeout`` value is not elapsed.
143+
135144
* other :ref:`net.box options <net_box-options>`, such as ``is_async``,
136145
``buffer``, ``on_push`` are also supported.
137146

@@ -163,12 +172,16 @@ Router public API
163172
optional attribute containing a message with the human-readable error description,
164173
and other attributes specific for the error code.
165174

175+
.. reference_vshard_note_start
176+
166177
.. note::
167178

168-
Any write requests that are intended to be executed repeatedly should be idempotent.
179+
Any write requests that are intended to be executed repeatedly (for example, retried after an error) should be idempotent.
169180
The operations' idempotency ensures that the change is applied **only once**.
170181
Read more: :ref:`<vshard-deduplication>`.
171182

183+
.. reference_vshard_note_end
184+
172185
**Examples:**
173186

174187
To call ``customer_add`` function from ``vshard/example``, say:
@@ -205,6 +218,13 @@ Router public API
205218
* ``timeout`` — a request timeout, in seconds.If the ``router`` cannot identify a
206219
shard with the specified ``bucket_id``, it will retry until the timeout is reached.
207220

221+
* ``request_timeout`` (since ``vshard`` 0.1.28) — timeout in seconds that serves as a protection against hung replicas.
222+
It is necessary to pass the ``request_timeout`` and ``timeout`` parameters together, with the following requirement:
223+
``timeout > request_timeout``.
224+
The ``timeout`` parameter controls how much time a single request attempt may take.
225+
When this time is over (the ``TimedOut`` error is raised), router retries the request on the next replica as long
226+
as the ``timeout`` value is not elapsed.
227+
208228
* other :ref:`net.box options <net_box-options>`, such as ``is_async``,
209229
``buffer``, ``on_push`` are also supported.
210230

@@ -254,6 +274,10 @@ Router public API
254274
optional attribute containing a message with the human-readable error description,
255275
and other attributes specific for this error code.
256276

277+
.. include:: /reference/reference_rock/vshard/vshard_router.rst
278+
:start-after: reference_vshard_note_start
279+
:end-before: reference_vshard_note_end
280+
257281
.. _router_api-callre:
258282

259283
.. function:: vshard.router.callre(bucket_id, function_name, {argument_list}, {options})
@@ -273,6 +297,13 @@ Router public API
273297
* ``timeout`` — a request timeout, in seconds. If the ``router`` cannot identify a
274298
shard with the specified ``bucket_id``, it will retry until the timeout is reached.
275299

300+
* ``request_timeout`` (since ``vshard`` 0.1.28) — timeout in seconds that serves as a protection against hung replicas.
301+
It is necessary to pass the ``request_timeout`` and ``timeout`` parameters together, with the following requirement:
302+
``timeout > request_timeout``.
303+
The ``timeout`` parameter controls how much time a single request attempt may take.
304+
When this time is over (the ``TimedOut`` error is raised), router retries the request on the next replica as long
305+
as the ``timeout`` value is not elapsed.
306+
276307
* other :ref:`net.box options <net_box-options>`, such as ``is_async``,
277308
``buffer``, ``on_push`` are also supported.
278309

0 commit comments

Comments
 (0)