Skip to content

Commit 099f855

Browse files
committed
DOCSP-46699: Retryable reads and writes (#165)
(cherry picked from commit b747af7)
1 parent c3b3f02 commit 099f855

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

source/connect/connection-options.txt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,28 @@ Read and Write Operations
258258
time plus this value, the server isn't eligible for selection.
259259
|
260260
| **Data Type**: `read_preferences <{+api-root+}pymongo/read_preferences.html#pymongo.read_preferences>`__
261-
| **Default**: ``{+int-data-type+}``
261+
| **Default**: {+int-data-type+}
262262
| **MongoClient Example**: ``localThresholdMS=35``
263263
| **Connection URI Example**: ``localThresholdMS=35``
264264

265-
For more information about the connection option in this section, see :ref:`pymongo-databases-collections`.
265+
* - **retryReads**
266+
- | Specifies whether the client retries supported read operations. For more
267+
information, see :manual:`Retryable Reads </core/retryable-reads/>` in the {+mdb-server+}
268+
manual.
269+
|
270+
| **Data Type**: {+bool-data-type+}
271+
| **Default**: ``True``
272+
| **MongoClient Example**: ``retryReads=False``
273+
| **Connection URI Example**: ``retryReads=false``
274+
275+
* - **retryWrites**
276+
- | Specifies whether the client retries supported write operations. For more
277+
information, see :manual:`Retryable Writes </core/retryable-writes/>` in the {+mdb-server+}
278+
manual.
279+
|
280+
| **Data Type**: {+bool-data-type+}
281+
| **Default**: ``True``
282+
| **MongoClient Example**: ``retryWrites=False``
283+
| **Connection URI Example**: ``retryWrites=false``
284+
285+
For more information about the connection options in this section, see :ref:`pymongo-databases-collections`.

source/databases-collections.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,25 @@ within 35 milliseconds of the closest member's ping time.
283283
:manual:`localThreshold </reference/program/mongos/#std-option-mongos.--localThreshold>`
284284
command-line option.
285285

286+
Retryable Reads and Writes
287+
~~~~~~~~~~~~~~~~~~~~~~~~~~
288+
289+
{+driver-short+} automatically retries certain read and write operations a single time
290+
if they fail due to a network or server error.
291+
292+
You can explicitly disable retryable reads or retryable writes by setting the ``retryReads`` or
293+
``retryWrites`` option to ``False`` in the ``MongoClient()`` constructor. The following
294+
example disables retryable reads and writes for a client:
295+
296+
.. code-block:: python
297+
298+
client = MongoClient("<connection string>",
299+
retryReads=False, retryWrites=False)
300+
301+
To learn more about supported retryable read operations, see :manual:`Retryable Reads </core/retryable-reads/>`
302+
in the {+mdb-server+} manual. To learn more about supported retryable write
303+
operations, see :manual:`Retryable Writes </core/retryable-writes/>` in the {+mdb-server+} manual.
304+
286305
Troubleshooting
287306
---------------
288307

0 commit comments

Comments
 (0)