You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -439,7 +464,7 @@ A change stream MUST track the last resume token, per `Updating the Cached Resum
439
464
440
465
Drivers MUST raise an error on the first document received without a resume token (e.g. the user has removed ``_id`` with a pipeline stage), and close the change stream. The error message SHOULD resemble “Cannot provide resume functionality when the resume token is missing”.
441
466
442
-
A change stream MUST attempt to resume a single time if it encounters any resumable error. A change stream MUST NOT attempt to resume on any other type of error, with the exception of a “not master” server error. If a driver receives a “not master” error (for instance, because the primary it was connected to is stepping down), it will treat the error as a resumable error and attempt to resume.
467
+
A change stream MUST attempt to resume a single time if it encounters any resumable error per `Resumable Error`_. A change stream MUST NOT attempt to resume on any other type of error.
443
468
444
469
In addition to tracking a resume token, change streams MUST also track the read preference specified when the change stream was created. In the event of a resumable error, a change stream MUST perform server selection with the original read preference before attempting to resume.
445
470
@@ -676,13 +701,14 @@ It was decided to remove this example from the specification for the following r
676
701
- There is something to be said for an API that allows cooperation by default. The model in which a call to next only blocks until any response is returned (even an empty batch), allows for interruption and cooperation (e.g. interaction with other event loops).
677
702
678
703
----------------------------------------
679
-
What do the additional error codes mean?
704
+
Why is a whitelist of error codes preferable to a blacklist?
680
705
----------------------------------------
681
706
682
-
The `CursorKilled` or `Interrupted` error implies some other actor killed the cursor.
683
-
684
-
The `CappedPositionLost` error implies falling off of the back of the oplog,
685
-
so resuming is impossible.
707
+
Change streams originally used a blacklist of error codes to determine which errors were not resumable. However, this
708
+
allowed for the possibility of infinite resume loops if an error was not correctly blacklisted. Due to the fact that
709
+
all errors aside from transient issues such as failovers are not resumable, the resume behavior was changed to use a
710
+
whitelist. Part of this change was to introduce the ``ResumableChangeStreamError`` label so the server can add new error
711
+
codes to the whitelist without requiring changes to drivers.
Copy file name to clipboardExpand all lines: source/change-streams/tests/README.rst
+8-5Lines changed: 8 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -93,7 +93,10 @@ Spec Test Runner
93
93
94
94
Before running the tests
95
95
96
-
- Create a MongoClient ``globalClient``, and connect to the server
96
+
- Create a MongoClient ``globalClient``, and connect to the server.
97
+
When executing tests against a sharded cluster, ``globalClient`` must only connect to one mongos. This is because tests
98
+
that set failpoints will only work consistently if both the ``configureFailPoint`` and failing commands are sent to the
99
+
same mongos.
97
100
98
101
For each YAML file, for each element in ``tests``:
99
102
@@ -128,8 +131,8 @@ For each YAML file, for each element in ``tests``:
128
131
- If there are any ``expectations``
129
132
130
133
- For each (``expected``, ``idx``) in ``expectations``
131
-
132
-
- Assert that ``actual[idx]`` MATCHES ``expected``
134
+
- If ``actual[idx]`` is a ``killCursors`` event, skip it and move to ``actual[idx+1]``.
135
+
- Else assert that ``actual[idx]`` MATCHES ``expected``
133
136
134
137
- Close the MongoClient ``client``
135
138
@@ -155,12 +158,12 @@ The following tests have not yet been automated, but MUST still be tested. All t
155
158
#. ``ChangeStream`` will throw an exception if the server response is missing the resume token (if wire version is < 8, this is a driver-side error; for 8+, this is a server-side error)
156
159
#. After receiving a ``resumeToken``, ``ChangeStream`` will automatically resume one time on a resumable error with the initial pipeline and options, except for the addition/update of a ``resumeToken``.
157
160
#. ``ChangeStream`` will not attempt to resume on any error encountered while executing an ``aggregate`` command. Note that retryable reads may retry ``aggregate`` commands. Drivers should be careful to distinguish retries from resume attempts. Alternatively, drivers may specify `retryReads=false` or avoid using a [retryable error](../../retryable-reads/retryable-reads.rst#retryable-error) for this test.
158
-
#. ``ChangeStream`` will not attempt to resume after encountering error code 11601 (Interrupted), 136 (CappedPositionLost), or 237 (CursorKilled) while executing a ``getMore`` command.
161
+
#. **Removed**
159
162
#. ``ChangeStream`` will perform server selection before attempting to resume, using initial ``readPreference``
160
163
#. Ensure that a cursor returned from an aggregate command with a cursor id and an initial empty batch is not closed on the driver side.
161
164
#. The ``killCursors`` command sent during the "Resume Process" must not be allowed to throw an exception.
162
165
#. ``$changeStream`` stage for ``ChangeStream`` against a server ``>=4.0`` and ``<4.0.7`` that has not received any results yet MUST include a ``startAtOperationTime`` option when resuming a change stream.
163
-
#. ``ChangeStream`` will resume after a ``killCursors`` command is issued for its child cursor.
0 commit comments