Skip to content

DOCSP-46699: Retryable reads and writes #165

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions source/connect/connection-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,28 @@ Read and Write Operations
time plus this value, the server isn't eligible for selection.
|
| **Data Type**: `read_preferences <{+api-root+}pymongo/read_preferences.html#pymongo.read_preferences>`__
| **Default**: ``{+int-data-type+}``
| **Default**: {+int-data-type+}
| **MongoClient Example**: ``localThresholdMS=35``
| **Connection URI Example**: ``localThresholdMS=35``

For more information about the connection option in this section, see :ref:`pymongo-databases-collections`.
* - **retryReads**
- | Specifies whether the client retries supported read operations. For more
information, see :manual:`Retryable Reads </core/retryable-reads/>` in the {+mdb-server+}
manual.
|
| **Data Type**: {+bool-data-type+}
| **Default**: ``True``
| **MongoClient Example**: ``retryReads=False``
| **Connection URI Example**: ``retryReads=false``

* - **retryWrites**
- | Specifies whether the client retries supported write operations. For more
information, see :manual:`Retryable Writes </core/retryable-writes/>` in the {+mdb-server+}
manual.
|
| **Data Type**: {+bool-data-type+}
| **Default**: ``True``
| **MongoClient Example**: ``retryWrites=False``
| **Connection URI Example**: ``retryWrites=false``

For more information about the connection options in this section, see :ref:`pymongo-databases-collections`.
19 changes: 19 additions & 0 deletions source/databases-collections.txt
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,25 @@ within 35 milliseconds of the closest member's ping time.
:manual:`localThreshold </reference/program/mongos/#std-option-mongos.--localThreshold>`
command-line option.

Retryable Reads and Writes
~~~~~~~~~~~~~~~~~~~~~~~~~~

{+driver-short+} automatically retries certain read and write operations a single time
if they fail due to a network or server error.

You can explicitly disable retryable reads or retryable writes by setting the ``retryReads`` or
``retryWrites`` option to ``False`` in the ``MongoClient()`` constructor. The following
example disables retryable reads and writes for a client:

.. code-block:: python

client = MongoClient("<connection string>",
retryReads=False, retryWrites=False)

To learn more about supported retryable read operations, see :manual:`Retryable Reads </core/retryable-reads/>`
in the {+mdb-server+} manual. To learn more about supported retryable write
operations, see :manual:`Retryable Writes </core/retryable-writes/>` in the {+mdb-server+} manual.

Troubleshooting
---------------

Expand Down
Loading