Skip to content

Commit

Permalink
Cleanup; improve prose tests
Browse files Browse the repository at this point in the history
  • Loading branch information
comandeo-mongo committed Aug 21, 2023
1 parent 1786155 commit 49fe649
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 34 deletions.
9 changes: 7 additions & 2 deletions source/retryable-reads/retryable-reads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,10 @@ selecting a server for a retry attempt.
3a. Selecting the server for retry
''''''''''''''''''''''''''''''''''

The server on which the operation failed MUST be provided to the server selection
mechanism as a deprioritized server. If the driver cannot select a server for
In sharded topology, the server on which the operation failed MUST be provided
to the server selection mechanism as a deprioritized server.

If the driver cannot select a server for
a retry attempt or the newly selected server does not support retryable reads,
retrying is not possible and drivers MUST raise the previous retryable error.
In both cases, the caller is able to infer that an attempt was made.
Expand Down Expand Up @@ -690,6 +692,9 @@ degraded performance can simply disable ``retryableReads``.
Changelog
=========
:2023-08-??: Require that in a sharded topology the server on which the
operation failed MUST be provided to the server selection
mechanism as a deprioritized server.
:2022-11-09: CLAM must apply both events and log messages.
:2022-10-18: When CSOT is enabled multiple retry attempts may occur.
:2022-10-05: Remove spec front matter, move footnote, and reformat changelog.
Expand Down
34 changes: 27 additions & 7 deletions source/retryable-reads/tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,23 @@ mongos instances.
mongoses. If there are more than two mongoses in the cluster, pick two to
test against.

2. Create a client per mongos using the direct connection, and configure fail
points on each of the picked mongoses, so that each mongos raises
a retryable error once.
2. Create a client per mongos using the direct connection, and configure the
following fail points on each mongos::

{
configureFailPoint: "failCommand",
mode: { times: 1 },
data: {
failCommands: ["find"],
errorCode: 6,
closeConnection: true
}
}

3. Create a client with ``retryReads=true`` that connects to the cluster,
providing the two selected mongoses as seeds.

4. Enable command monitoring, and execute a read command that is
4. Enable command monitoring, and execute ``find`` command that is
supposed to fail on both mongoses.

5. Asserts that there were failed command events from each mongos.
Expand All @@ -270,13 +279,22 @@ Retryable Reads Are Retried on the Same Mongos if No Other Available
mongoses in the cluster, pick one to test against.

2. Create a client that connects to the mongos using the direct connection,
and configure a fail point so that the mongos raises a retryable error once.
and configure the following fail point on the mongos::

{
configureFailPoint: "failCommand",
mode: { times: 1 },
data: {
failCommands: ["find"],
errorCode: 6,
closeConnection: true
}
}

3. Create a client with ``retryReads=true`` that connects to the cluster,
providing the selected mongos as the seed.

4. Enable command monitoring, and execute a read command that is
supposed to fail.
4. Enable command monitoring, and execute ``find`` command.

5. Asserts that there was a failed command and a successful command event.

Expand All @@ -286,6 +304,8 @@ Retryable Reads Are Retried on the Same Mongos if No Other Available
Changelog
=========

:2023-08-??: Add prose tests for retrying in a sharded cluster.

:2022-04-22: Clarifications to ``serverless`` and ``useMultipleMongoses``.

:2022-01-10: Create legacy and unified subdirectories for new unified tests
Expand Down
11 changes: 8 additions & 3 deletions source/retryable-writes/retryable-writes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,9 +395,11 @@ of the following conditions is reached:
<../client-side-operations-timeout/client-side-operations-timeout.rst#retryability>`__.
- CSOT is not enabled and one retry was attempted.

For each retry attempt, drivers MUST select a writable server. Server on which
the operation failed MUST be provided to the server selection mechanism as
a deprioritized server. If the driver cannot select a server for a retry attempt
For each retry attempt, drivers MUST select a writable server. In sharded
topology, the server on which the operation failed MUST be provided to
the server selection mechanism as a deprioritized server.

If the driver cannot select a server for a retry attempt
or the selected server does not support retryable writes, retrying is not
possible and drivers MUST raise the retryable error from the previous attempt.
In both cases, the caller is able to infer that an attempt was made.
Expand Down Expand Up @@ -827,6 +829,9 @@ inconsistent with the server and potentially confusing to developers.
Changelog
=========
:2023-08-??: Require that in a sharded topology the server on which the
operation failed MUST be provided to the server selection
mechanism as a deprioritized server.
:2022-11-17: Add logic for persisting "currentError" as "previousError" on first
retry attempt, avoiding raising "null" errors.
:2022-11-09: CLAM must apply both events and log messages.
Expand Down
68 changes: 46 additions & 22 deletions source/retryable-writes/tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -462,47 +462,70 @@ and sharded clusters.
This test MUST be executed against a sharded cluster that has at least two
mongos instances.

1. Ensure that a test is run against a sharded cluster that has at least two
mongoses. If there are more than two mongoses in the cluster, pick two to
test against.
1. Ensure that a test is run against a sharded cluster that has at least two
mongoses. If there are more than two mongoses in the cluster, pick two to
test against.

2. Create a client per mongos using the direct connection, and configure fail
points on each of the picked mongoses, so that each mongos raises
a retryable error once.
2. Create a client per mongos using the direct connection, and configure the
following fail point on each mongos::

3. Create a client with ``retryWrites=true`` that connects to the cluster,
providing the two selected mongoses as seeds.
{
configureFailPoint: "failCommand",
mode: { times: 1 },
data: {
failCommands: ["insert"],
errorCode: 6,
errorLabels: ["RetryableWriteError"],
closeConnection: true
}
}

4. Enable command monitoring, and execute a write command that is
supposed to fail on both mongoses.
3. Create a client with ``retryWrites=true`` that connects to the cluster,
providing the two selected mongoses as seeds.

5. Asserts that there were failed command events from each mongos.
4. Enable command monitoring, and execute a write command that is
supposed to fail on both mongoses.

6. Disable the fail points.
5. Asserts that there were failed command events from each mongos.

6. Disable the fail points.

#. Test that in a sharded cluster on the same mongos if no other available

This test MUST be executed against a sharded cluster

1. Ensure that a test is run against a sharded cluster. If there are multiple
mongoses in the cluster, pick one to test against.
1. Ensure that a test is run against a sharded cluster. If there are multiple
mongoses in the cluster, pick one to test against.

2. Create a client that connects to the mongos using the direct connection,
and configure the following fail point on the mongos::

2. Create a client that connects to the mongos using the direct connection,
and configure a fail point so that the mongos raises a retryable error once.
{
configureFailPoint: "failCommand",
mode: { times: 1 },
data: {
failCommands: ["insert"],
errorCode: 6,
errorLabels: ["RetryableWriteError"],
closeConnection: true
}
}

3. Create a client with ``retryWrites=true`` that connects to the cluster,
providing the selected mongos as the seed.
3. Create a client with ``retryWrites=true`` that connects to the cluster,
providing the selected mongos as the seed.

4. Enable command monitoring, and execute a write command that is
supposed to fail.
4. Enable command monitoring, and execute a write command that is
supposed to fail.

5. Asserts that there was a failed command and a successful command event.
5. Asserts that there was a failed command and a successful command event.

6. Disable the fail point.
6. Disable the fail point.

Changelog
=========

:2023-08-??: Add prose tests for retrying in a sharded cluster.

:2022-08-30: Add prose test verifying correct error handling for errors with
the NoWritesPerformed label, which is to return the original
error.
Expand All @@ -529,3 +552,4 @@ Changelog
which are now expressed within ``runOn`` elements.

Add test-level ``useMultipleMongoses`` field.
``
1 change: 1 addition & 0 deletions source/server-selection/server-selection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2074,3 +2074,4 @@ Changelog
:2022-01-19: Require that timeouts be applied per the client-side operations timeout spec
:2022-10-05: Remove spec front matter, move footnote, and reformat changelog.
:2022-11-09: Add log messages and tests.
:2023-08-??: Add list of deprioritized servers for sharded cluster topology.

0 comments on commit 49fe649

Please sign in to comment.