Skip to content

Commit a9790ac

Browse files
authored
DRIVERS-1293: Updated change streams spec and tests to use modern terminology (#972)
1 parent 0a5b00b commit a9790ac

7 files changed

+35
-33
lines changed

source/change-streams/change-streams.rst

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Change Streams
99
:Status: Accepted
1010
:Type: Standards
1111
:Minimum Server Version: 3.6
12-
:Last Modified: Febrary 8, 2021
13-
:Version: 1.9.0
12+
:Last Modified: April 23, 2021
13+
:Version: 1.9.1
1414

1515
.. contents::
1616

@@ -76,15 +76,15 @@ executed when checking these constraints.
7676
- 262
7777
* - SocketException
7878
- 9001
79-
* - NotMaster
79+
* - NotWritablePrimary
8080
- 10107
8181
* - InterruptedAtShutdown
8282
- 11600
8383
* - InterruptedDueToReplStateChange
8484
- 11602
85-
* - NotMasterNoSlaveOk
85+
* - NotPrimaryNoSecondaryOk
8686
- 13435
87-
* - NotMasterOrSecondary
87+
* - NotPrimaryOrSecondary
8888
- 13436
8989
* - StaleShardVersion
9090
- 63
@@ -404,7 +404,7 @@ Driver API
404404
* The server will report an error if `startAfter` and `resumeAfter` are both specified.
405405
*
406406
* @since 4.1.1
407-
* @see https://docs.mongodb.com/master/changeStreams/#change-stream-start-after
407+
* @see https://docs.mongodb.com/manual/changeStreams/#change-stream-start-after
408408
* @note this is an option of the `$changeStream` pipeline stage.
409409
*/
410410
startAfter: Optional<Document>;
@@ -748,15 +748,15 @@ It was decided to remove this example from the specification for the following r
748748
- There are considerations to be made for languages that do not permit interruptible I/O (such as Java), where a change stream which blocks forever in a separate thread would necessitate killing the thread.
749749
- 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).
750750

751-
----------------------------------------
752-
Why is a whitelist of error codes preferable to a blacklist?
753-
----------------------------------------
751+
--------------------------------------------------------------
752+
Why is an allow list of error codes preferable to a deny list?
753+
--------------------------------------------------------------
754754

755-
Change streams originally used a blacklist of error codes to determine which errors were not resumable. However, this
756-
allowed for the possibility of infinite resume loops if an error was not correctly blacklisted. Due to the fact that
757-
all errors aside from transient issues such as failovers are not resumable, the resume behavior was changed to use a
758-
whitelist. Part of this change was to introduce the ``ResumableChangeStreamError`` label so the server can add new error
759-
codes to the whitelist without requiring changes to drivers.
755+
Change streams originally used a deny list of error codes to determine which errors were not resumable. However, this
756+
allowed for the possibility of infinite resume loops if an error was not correctly deny listed. Due to the fact that
757+
all errors aside from transient issues such as failovers are not resumable, the resume behavior was changed to use an
758+
allow list. Part of this change was to introduce the ``ResumableChangeStreamError`` label so the server can add new error
759+
codes to the allow list without requiring changes to drivers.
760760

761761
----------------------------------------------------------------------
762762
Why is ``CursorNotFound`` special-cased when determining resumability?
@@ -881,7 +881,9 @@ Changelog
881881
| 2019-07-15 | Clarify resume process for change streams started with |
882882
| | the ``startAfter`` option. |
883883
+------------+------------------------------------------------------------+
884-
| 2020-02-10 | Changed error handling approach to use a whitelist |
884+
| 2020-02-10 | Changed error handling approach to use an allow list |
885885
+------------+------------------------------------------------------------+
886886
| 2021-02-08 | Added the ``UpdateDescription.truncatedArrays`` field |
887887
+------------+------------------------------------------------------------+
888+
| 2021-04-23 | Updated to use modern terminology |
889+
+------------+------------------------------------------------------------+

source/change-streams/tests/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ For each YAML file, for each element in ``tests``:
121121
Transactions spec test documentation for more information.
122122

123123
- Create a new MongoClient ``client``
124-
- Begin monitoring all APM events for ``client``. (If the driver uses global listeners, filter out all events that do not originate with ``client``). Filter out any "internal" commands (e.g. ``isMaster``)
124+
- Begin monitoring all APM events for ``client``. (If the driver uses global listeners, filter out all events that do not originate with ``client``). Filter out any "internal" commands (e.g. ``hello`` or legacy hello)
125125
- Using ``client``, create a changeStream ``changeStream`` against the specified ``target``. Use ``changeStreamPipeline`` and ``changeStreamOptions`` if they are non-empty. Capture any error.
126126
- If there was no error, use ``globalClient`` and run every operation in ``operations`` in serial against the server until all operations have been executed or an error is thrown. Capture any error.
127127
- If there was no error and ``result.error`` is set, iterate ``changeStream`` once and capture any error.

source/change-streams/tests/legacy/change-streams-errors.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ tests:
8080
mode: { times: 1 }
8181
data:
8282
failCommands: ["getMore"]
83-
errorCode: 216 # An error code that's not on the old blacklist or whitelist
83+
errorCode: 216 # An error code that's not on the old deny or allow lists
8484
closeConnection: false
8585
target: collection
8686
topology:

source/change-streams/tests/legacy/change-streams-resume-whitelist.json renamed to source/change-streams/tests/legacy/change-streams-resume-allowlist.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@
777777
}
778778
},
779779
{
780-
"description": "change stream resumes after NotMaster",
780+
"description": "change stream resumes after NotWritablePrimary",
781781
"minServerVersion": "4.2",
782782
"maxServerVersion": "4.2.99",
783783
"failPoint": {
@@ -1068,7 +1068,7 @@
10681068
}
10691069
},
10701070
{
1071-
"description": "change stream resumes after NotMasterNoSlaveOk",
1071+
"description": "change stream resumes after NotPrimaryNoSecondaryOk",
10721072
"minServerVersion": "4.2",
10731073
"maxServerVersion": "4.2.99",
10741074
"failPoint": {
@@ -1165,7 +1165,7 @@
11651165
}
11661166
},
11671167
{
1168-
"description": "change stream resumes after NotMasterOrSecondary",
1168+
"description": "change stream resumes after NotPrimaryOrSecondary",
11691169
"minServerVersion": "4.2",
11701170
"maxServerVersion": "4.2.99",
11711171
"failPoint": {

source/change-streams/tests/legacy/change-streams-resume-whitelist.yml renamed to source/change-streams/tests/legacy/change-streams-resume-allowlist.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ tests:
521521
x:
522522
$numberInt: "1"
523523
-
524-
description: "change stream resumes after NotMaster"
524+
description: "change stream resumes after NotWritablePrimary"
525525
minServerVersion: "4.2"
526526
maxServerVersion: "4.2.99"
527527
failPoint:
@@ -716,7 +716,7 @@ tests:
716716
x:
717717
$numberInt: "1"
718718
-
719-
description: "change stream resumes after NotMasterNoSlaveOk"
719+
description: "change stream resumes after NotPrimaryNoSecondaryOk"
720720
minServerVersion: "4.2"
721721
maxServerVersion: "4.2.99"
722722
failPoint:
@@ -781,7 +781,7 @@ tests:
781781
x:
782782
$numberInt: "1"
783783
-
784-
description: "change stream resumes after NotMasterOrSecondary"
784+
description: "change stream resumes after NotPrimaryOrSecondary"
785785
minServerVersion: "4.2"
786786
maxServerVersion: "4.2.99"
787787
failPoint:

source/change-streams/tests/legacy/change-streams-resume-errorLabels.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@
654654
}
655655
},
656656
{
657-
"description": "change stream resumes after NotMaster",
657+
"description": "change stream resumes after NotWritablePrimary",
658658
"minServerVersion": "4.3.1",
659659
"failPoint": {
660660
"configureFailPoint": "failGetMoreAfterCursorCheckout",
@@ -933,7 +933,7 @@
933933
}
934934
},
935935
{
936-
"description": "change stream resumes after NotMasterNoSlaveOk",
936+
"description": "change stream resumes after NotPrimaryNoSecondaryOk",
937937
"minServerVersion": "4.3.1",
938938
"failPoint": {
939939
"configureFailPoint": "failGetMoreAfterCursorCheckout",
@@ -1026,7 +1026,7 @@
10261026
}
10271027
},
10281028
{
1029-
"description": "change stream resumes after NotMasterOrSecondary",
1029+
"description": "change stream resumes after NotPrimaryOrSecondary",
10301030
"minServerVersion": "4.3.1",
10311031
"failPoint": {
10321032
"configureFailPoint": "failGetMoreAfterCursorCheckout",

source/change-streams/tests/legacy/change-streams-resume-errorLabels.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ tests:
444444
x:
445445
$numberInt: "1"
446446
-
447-
description: "change stream resumes after NotMaster"
447+
description: "change stream resumes after NotWritablePrimary"
448448
minServerVersion: "4.3.1"
449449
failPoint:
450450
configureFailPoint: failGetMoreAfterCursorCheckout
@@ -633,7 +633,7 @@ tests:
633633
x:
634634
$numberInt: "1"
635635
-
636-
description: "change stream resumes after NotMasterNoSlaveOk"
636+
description: "change stream resumes after NotPrimaryNoSecondaryOk"
637637
minServerVersion: "4.3.1"
638638
failPoint:
639639
configureFailPoint: failGetMoreAfterCursorCheckout
@@ -696,7 +696,7 @@ tests:
696696
x:
697697
$numberInt: "1"
698698
-
699-
description: "change stream resumes after NotMasterOrSecondary"
699+
description: "change stream resumes after NotPrimaryOrSecondary"
700700
minServerVersion: "4.3.1"
701701
failPoint:
702702
configureFailPoint: failGetMoreAfterCursorCheckout
@@ -1010,7 +1010,7 @@ tests:
10101010
fullDocument:
10111011
x:
10121012
$numberInt: "1"
1013-
# The next two tests ensure that the driver only uses the error label, not the whitelist.
1013+
# The next two tests ensure that the driver only uses the error label, not the allow list.
10141014
-
10151015
description: "change stream resumes if error contains ResumableChangeStreamError"
10161016
minServerVersion: "4.3.1"
@@ -1019,7 +1019,7 @@ tests:
10191019
mode: { times: 1 }
10201020
data:
10211021
failCommands: ["getMore"]
1022-
errorCode: 50 # Use an error code that does not have the whitelist label by default
1022+
errorCode: 50 # Use an error code that does not have the allow list label by default
10231023
closeConnection: false
10241024
errorLabels: ["ResumableChangeStreamError"]
10251025
target: collection
@@ -1080,11 +1080,11 @@ tests:
10801080
description: "change stream does not resume if error does not contain ResumableChangeStreamError"
10811081
minServerVersion: "4.3.1"
10821082
failPoint:
1083-
configureFailPoint: failCommand # failCommand will not add the whitelist error label
1083+
configureFailPoint: failCommand # failCommand will not add the allow list error label
10841084
mode: { times: 1 }
10851085
data:
10861086
failCommands: ["getMore"]
1087-
errorCode: 6 # Use an error code that is on the whitelist
1087+
errorCode: 6 # Use an error code that is on the allow list
10881088
closeConnection: false
10891089
target: collection
10901090
topology:

0 commit comments

Comments
 (0)