-
Notifications
You must be signed in to change notification settings - Fork 49
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
DOCSP-4466 Add CSOT #951
base: master
Are you sure you want to change the base?
DOCSP-4466 Add CSOT #951
Changes from 2 commits
1178d8d
0b8b950
0d5a095
703252c
381da04
9145ed6
20827e2
74770f0
d87f15c
f4134ad
0d5f77a
5f4f261
75909a9
b5d5f6d
1ed5035
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,90 +21,91 @@ Overview | |||||
|
||||||
When you use {+driver-short+} to perform a server operation, you can also limit | ||||||
the duration allowed for the server to finish the operation. To do so, | ||||||
specify a **client-side operation timeout**. The timeout applies to all steps | ||||||
specify a **client-side operation timeout (CSOT)**. The timeout applies to all steps | ||||||
needed to complete the operation, including server selection, connection | ||||||
checkout, serialization, and server-side execution. When the timeout expires, | ||||||
{+driver-short+} raises a timeout exception. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
the |
||||||
|
||||||
You can specify a timeout by using the ``timeoutMS`` option. | ||||||
|
||||||
.. note:: Experimental Feature | ||||||
|
||||||
The Client-Side Operation Timeout (CSOT) feature is experimental and might | ||||||
change in future driver releases. | ||||||
The CSOT feature is experimental and might change in future driver releases. | ||||||
|
||||||
timeoutMS Option | ||||||
---------------- | ||||||
|
||||||
You can specify the ``timeoutMS`` option in your ``MongoClientOptions`` | ||||||
instance or at the database, collection, session, transaction, or operation | ||||||
levels. | ||||||
|
||||||
To specify a timeout when connecting to a MongoDB deployment, set the | ||||||
``timeoutMS`` connection option to the timeout length in milliseconds. | ||||||
``timeoutMS`` connection option to the timeout length in milliseconds. You can | ||||||
specify the ``timeoutMS`` option in your ``MongoClientOptions`` instance or at | ||||||
the database, collection, session, transaction, or operation levels. | ||||||
|
||||||
The following code example uses the ``timeoutMS`` option to specify a timeout of | ||||||
10 seconds when instantiating a new ``MongoClient`` instance: | ||||||
|
||||||
.. code-block:: javascript | ||||||
|
||||||
const uri = "mongodb://<db_username>:<db_password>@<hostname:<port>"; | ||||||
const uri = "mongodb://<hostname:<port>"; | ||||||
const client = new MongoClient(uri, { | ||||||
timeoutMS: 10000 | ||||||
}); | ||||||
|
||||||
When you specify the ``timeoutMS`` option, it always takes precedence over the | ||||||
following options: | ||||||
.. note:: | ||||||
|
||||||
- ``socketTimeoutMS`` | ||||||
- ``waitQueueTimeoutMS`` | ||||||
- ``wTimeoutMS`` | ||||||
- ``maxTimeMS`` | ||||||
- ``maxCommitTimeMS`` | ||||||
The ``timeoutMS`` connection option takes precedence over the | ||||||
following options: | ||||||
|
||||||
.. note:: Experimental Feature | ||||||
- ``socketTimeoutMS`` | ||||||
- ``waitQueueTimeoutMS`` | ||||||
- ``wTimeoutMS`` | ||||||
- ``maxTimeMS`` | ||||||
- ``maxCommitTimeMS`` | ||||||
|
||||||
When the CSOT feature is no longer experimental, the preceding options will | ||||||
be deprecated. The ``timeoutMS`` option will superse the older, deprecated | ||||||
options. | ||||||
be deprecated. | ||||||
|
||||||
If you specify the ``timeoutMS`` option, the driver automatically applies the | ||||||
specified timeout to each server operation. The following code example specifies | ||||||
a timeout limit of 10 seconds at the collection level, and then calls the | ||||||
a timeout limit of 10 seconds at the client level, and then calls the | ||||||
stephmarie17 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
``insertOne()`` method: | ||||||
|
||||||
.. literalinclude:: /code-snippets/connection/csot-operation.js | ||||||
:language: javascript | ||||||
:start-after: start-operation | ||||||
:end-before: end-operation | ||||||
|
||||||
Inheritance Behavior | ||||||
~~~~~~~~~~~~~~~~~~~~ | ||||||
Timeout Inheritance | ||||||
~~~~~~~~~~~~~~~~~~~ | ||||||
|
||||||
When you specify a ``timeoutMS`` option, the driver applies the timeout | ||||||
according to the same inheritance behaviors as other {+driver-short+} options. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
S: Could put 'the' here as well, since you're talking about a specific set of options mentioned previously |
||||||
The following list describes how the timeout value is inherited at each level: | ||||||
The following table describes how the timeout value is inherited at each level: | ||||||
|
||||||
.. list-table:: | ||||||
:header-rows: 1 | ||||||
:widths: 30 70 | ||||||
|
||||||
- **Operation Level**: Takes the highest precedence and will override ``timeoutMS`` | ||||||
options set at any other level. | ||||||
* - Level | ||||||
- Inheritance Description | ||||||
|
||||||
- **Transaction Level**: Takes precedence over ``timeoutMS`` set at the session, | ||||||
collection, database, or client level. | ||||||
* - Operation | ||||||
- Takes the highest precedence and will override ``timeoutMS`` | ||||||
options set at any other level. | ||||||
|
||||||
- **Session Level**: Inherits to all transactions and operations within | ||||||
that session, unless the option is overridden by options set at those levels. | ||||||
* - Transaction | ||||||
- Takes precedence over ``timeoutMS`` set at the session, | ||||||
collection, database, or client level. | ||||||
|
||||||
- **Collection Level**: Inherits to all sessions and operations on that | ||||||
collection, unless the option is overridden by options set at those levels. | ||||||
* - Session | ||||||
- Applies to all transactions and operations within | ||||||
that session, unless the option is overridden by options set at those levels. | ||||||
|
||||||
- **Database Level**: Applies to all collections within that database. It is | ||||||
inherited by all sessions, collections, and operations within the collections | ||||||
on that database, unless the option is overridden by an option set at a level | ||||||
with higher precedence. | ||||||
* - Collection | ||||||
- Applies to all sessions and operations on that | ||||||
collection, unless the option is overridden by options set at those levels. | ||||||
|
||||||
- **Client Level**: Applies to all databases, collections, sessions, | ||||||
transactions, and operations within that client that do not otherwise specify | ||||||
``timeoutMS``. | ||||||
* - Client | ||||||
- Applies to all databases, collections, sessions, transactions, and | ||||||
operations within that client that do not otherwise specify | ||||||
``timeoutMS``. | ||||||
|
||||||
For more information on overrides and specific options, see the :ref:`Overrides | ||||||
<node-csot-overrides>` section. | ||||||
|
@@ -114,7 +115,7 @@ For more information on overrides and specific options, see the :ref:`Overrides | |||||
Overrides | ||||||
--------- | ||||||
|
||||||
The Node.js driver supports various levels of configuration to control the | ||||||
The {+driver-short+} supports various levels of configuration to control the | ||||||
behavior and performance of database operations. | ||||||
|
||||||
You can specify a ``timeoutMS`` option at the operation level to override the | ||||||
|
@@ -171,25 +172,25 @@ precedence. | |||||
Cursors | ||||||
------- | ||||||
|
||||||
Cursors require special handling when you use the CSOT feature. The | ||||||
``timeOutMS`` option is configurable on a per-cursor basis. You can configure | ||||||
cursors to interact with CSOT by using etiher the cursor lifetime or cursor | ||||||
Cursors require special handling when you use the CSOT feature. You can configure | ||||||
cursors to interact with CSOT by using either the cursor lifetime or cursor | ||||||
iteration mode. | ||||||
|
||||||
Cursor Lifetime Mode | ||||||
~~~~~~~~~~~~~~~~~~~~ | ||||||
|
||||||
The ``cursorLifetime`` mode uses ``timeoutMS`` to bound the entire lifetime of a | ||||||
cursor. This is the default timeout mode for non-tailable cursors, such as | ||||||
``find()``, ``aggregate()``, or ``listCollections()``. In this mode, the initialization | ||||||
of the cursor and all subsequent ``getMore()`` calls must finish within the limit | ||||||
specified with ``timeoutMS``. If they do not, the system throws a timeout error. | ||||||
The cursor lifetime mode uses ``timeoutMS`` to limit the entire lifetime of a | ||||||
cursor. This is the default timeout mode for non-tailable cursors, such as those | ||||||
returned by the ``find()``, ``aggregate()``, or ``listCollections()`` methods. | ||||||
stephmarie17 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
In this mode, the initialization of the cursor and all subsequent calls to the | ||||||
``getMore()`` method must finish within the limit specified by the ``timeoutMS`` | ||||||
option. If they do not, the system throws a timeout error. | ||||||
|
||||||
Closing a cursor, either as part of a ``toArray()`` call or manually using the | ||||||
``close()`` method, resets the timeout. | ||||||
When you close a cursor by calling the ``toArray()``or ``close()`` method, the | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I: The space fixes the formatting on the page! |
||||||
timeout resets. | ||||||
|
||||||
Set the ``timeoutMS`` option to ensure the cursor initialization and retrieval | ||||||
of all documents occur within 10 seconds, as shown in the following example: | ||||||
The following example shows how to set the ``timeoutMS`` option to ensure that | ||||||
the cursor is initialized and all documents are retrieved within 10 seconds: | ||||||
|
||||||
.. code-block:: javascript | ||||||
|
||||||
|
@@ -198,10 +199,11 @@ of all documents occur within 10 seconds, as shown in the following example: | |||||
Cursor Iteration Mode | ||||||
~~~~~~~~~~~~~~~~~~~~~ | ||||||
|
||||||
The iteration mode uses ``timeoutMS`` to bind each ``next()``, ``hasNext()``, or | ||||||
``tryNext()`` call. The timeout refreshes after each call completes. This is the | ||||||
default mode for all tailable cursors, such as tailable ``find()`` cursors on | ||||||
capped collections or change streams. | ||||||
The cursor iteration mode uses the ``timeoutMS`` option to limit each call to | ||||||
the ``next()``, ``hasNext()``, or ``tryNext()`` method. The timeout refreshes | ||||||
after each call completes. This is the default mode for all tailable cursors, | ||||||
such as the tailable cursors returned by the ``find()`` method on capped | ||||||
collections or change streams. | ||||||
|
||||||
As shown in the following example, the cursor continues to fetch new documents | ||||||
as they are added to a collection, and then times out if it takes longer than 10 | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: I think we normally put 'the' in front of the the driver name!