diff --git a/source/retryable-reads/retryable-reads.md b/source/retryable-reads/retryable-reads.md index d715f774ef..63837c1a6a 100644 --- a/source/retryable-reads/retryable-reads.md +++ b/source/retryable-reads/retryable-reads.md @@ -207,8 +207,8 @@ capture this original retryable error. Drivers should then proceed with selectin ###### 3a. Selecting the server for retry -In a sharded cluster, the server on which the operation failed MUST be provided to the server selection mechanism as a -deprioritized server. +The server address on which the operation failed MUST be provided to the server selection mechanism as a member of the +deprioritized server address list. 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 @@ -284,6 +284,7 @@ function executeRetryableRead(command, session) { Exception previousError = null; retrying = false; Server previousServer = null; + deprioritizedServers = []; while true { if (previousError != null) { retrying = true; @@ -292,9 +293,9 @@ function executeRetryableRead(command, session) { if (previousServer == null) { server = selectServer(); } else { - // If a previous attempt was made, deprioritize the previous server + // If a previous attempt was made, deprioritize the previous server address // where the command failed. - deprioritizedServers = [ previousServer ]; + deprioritizedServers.push(previousServer.address); server = selectServer(deprioritizedServers); } } catch (ServerSelectionException exception) { @@ -547,6 +548,8 @@ any customers experiencing degraded performance can simply disable `retryableRea ## Changelog +- 2026-12-08: Clarified that server deprioritization during retries must use a list of server addresses. + - 2024-04-30: Migrated from reStructuredText to Markdown. - 2023-12-05: Add that any server information associated with retryable exceptions MUST reflect the originating server, diff --git a/source/retryable-writes/retryable-writes.md b/source/retryable-writes/retryable-writes.md index 609de18b92..85f81485d8 100644 --- a/source/retryable-writes/retryable-writes.md +++ b/source/retryable-writes/retryable-writes.md @@ -317,8 +317,8 @@ Drivers MUST then retry the operation as many times as necessary until any one o - CSOT is not enabled and one retry was attempted. -For each retry attempt, drivers MUST select a writable server. In a sharded cluster, the server on which the operation -failed MUST be provided to the server selection mechanism as a deprioritized server. +For each retry attempt, drivers MUST select a writable server. The server address on which the operation failed MUST be +provided to the server selection mechanism as a member of the deprioritized server address list. 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 @@ -377,6 +377,7 @@ function executeRetryableWrite(command, session) { Exception previousError = null; retrying = false; + deprioritizedServers = []; while true { try { return executeCommand(server, retryableCommand); @@ -418,13 +419,13 @@ function executeRetryableWrite(command, session) { } /* - * We try to select server that is not the one that failed by passing the - * failed server as a deprioritized server. + * We try to select a server that has not already failed by adding the + * failed server to the list of deprioritized servers passed to selectServer. * If we cannot select a writable server, do not proceed with retrying and * throw the previous error. The caller can then infer that an attempt was * made and failed. */ try { - deprioritizedServers = [ server ]; + deprioritizedServers.push(server.address); server = selectServer("writable", deprioritizedServers); } catch (Exception ignoredError) { throw previousError; @@ -680,6 +681,8 @@ retryWrites is not true would be inconsistent with the server and potentially co ## Changelog +- 2026-12-08: Clarified that server deprioritization during retries must use a list of server addresses. + - 2024-05-08: Add guidance for client-level `bulkWrite()` retryability. - 2024-05-02: Migrated from reStructuredText to Markdown. diff --git a/source/server-selection/server-selection-tests.md b/source/server-selection/server-selection-tests.md index 8b07b1da13..eb055242a9 100644 --- a/source/server-selection/server-selection-tests.md +++ b/source/server-selection/server-selection-tests.md @@ -40,15 +40,19 @@ The following test cases can be found in YAML form in the "tests" directory. Eac representing a set of servers, a ReadPreference document, and sets of servers returned at various stages of the server selection process. These sets are described below. Note that it is not required to test for correctness at every step. -| Test Case | Description | -| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| `suitable_servers` | the set of servers matching all server selection logic. | -| `in_latency_window` | the subset of `suitable_servers` that falls within the allowable latency window (required). NOTE: tests use the default localThresholdMS of 15 ms. | +| Test Case | Description | +| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| `suitable_servers` | the set of servers matching all server selection logic. | +| `in_latency_window` | the subset of `suitable_servers` that falls within the allowable latency window (required). NOTE: tests use the default localThresholdMS of 15 ms. | +| `deprioritized_servers` | the set of servers that are deprioritized and must only be selected if no other suitable server exists. | Drivers implementing server selection MUST test that their implementations correctly return **one** of the servers in `in_latency_window`. Drivers SHOULD test against the full set of servers in `in_latency_window` and against `suitable_servers` if possible. +For tests containing `deprioritized_servers`, drivers MUST pass the given list of deprioritized servers to each server +selection call. + ### Topology Type Single - The single server is always selected. diff --git a/source/server-selection/server-selection.md b/source/server-selection/server-selection.md index 6d65643f0f..39c2bf3aa4 100644 --- a/source/server-selection/server-selection.md +++ b/source/server-selection/server-selection.md @@ -708,9 +708,10 @@ For multi-threaded clients, the server selection algorithm is as follows: ["Server selection started" message](#server-selection-started-message). 2. If the topology wire version is invalid, raise an error and log a ["Server selection failed" message](#server-selection-failed-message). -3. Find suitable servers by topology type and operation type. If a list of deprioritized servers is provided, and the - topology is a sharded cluster, these servers should be selected only if there are no other suitable servers. The - server selection algorithm MUST ignore the deprioritized servers if the topology is not a sharded cluster. +3. Find suitable servers as follows: + - Filter out any deprioritized server addresses. + - Find suitable servers from the filtered list by topology type and operation type. + - If there are no suitable servers, perform the previous step again without filtering out deprioritized servers. 4. Filter the suitable servers by calling the optional, application-provided server selector. 5. If there are any suitable servers, filter them according to [Filtering suitable servers based on the latency window](#filtering-suitable-servers-based-on-the-latency-window) @@ -756,9 +757,10 @@ Therefore, for single-threaded clients, the server selection algorithm is as fol longer stale) 5. If the topology wire version is invalid, raise an error and log a ["Server selection failed" message](#server-selection-failed-message). -6. Find suitable servers by topology type and operation type. If a list of deprioritized servers is provided, and the - topology is a sharded cluster, these servers should be selected only if there are no other suitable servers. The - server selection algorithm MUST ignore the deprioritized servers if the topology is not a sharded cluster. +6. Find suitable servers as follows: + - Filter out any deprioritized server addresses. + - Find suitable servers from the filtered list by topology type and operation type. + - If there are no suitable servers, perform the previous step again without filtering out deprioritized servers. 7. Filter the suitable servers by calling the optional, application-provided server selector. 8. If there are any suitable servers, filter them according to [Filtering suitable servers based on the latency window](#filtering-suitable-servers-based-on-the-latency-window) @@ -846,10 +848,12 @@ details on each step, and [why is maxStalenessSeconds applied before tag_sets?](#why-is-maxstalenessseconds-applied-before-tag_sets).) If `mode` is 'secondaryPreferred', attempt the selection algorithm with `mode` 'secondary' and the user's -`maxStalenessSeconds` and `tag_sets`. If no server matches, select the primary. +`maxStalenessSeconds` and `tag_sets`. If no server matches, select the primary. Note that if all secondaries are +deprioritized, the primary MUST be selected if it is available. If `mode` is 'primaryPreferred', select the primary if it is known, otherwise attempt the selection algorithm with -`mode` 'secondary' and the user's `maxStalenessSeconds` and `tag_sets`. +`mode` 'secondary' and the user's `maxStalenessSeconds` and `tag_sets`. Note that if the primary is deprioritized, a +secondary MUST be selected if one is available. For all read preferences modes except 'primary', clients MUST set the `SecondaryOk` wire protocol flag (OP_QUERY) or `$readPreference` global command argument (OP_MSG) to ensure that any suitable server can handle the request. If the @@ -1605,6 +1609,16 @@ filter it out because it is too stale, and be left with no eligible servers. The user's intent in specifying two tag sets was to fall back to the second set if needed, so we filter by maxStalenessSeconds first, then tag_sets, and select Node 2. +### Why does server deprioritization use only server addresses and not ServerDescription objects? + +A server's address is the minimum identifying attribute that stays constant for across topology changes. Drivers create +new ServerDescription objects on each topology change, and since ServerDescription objects check multiple attributes to +determine equality comparisons, a deprioritized server could become non-equal to itself after a change and therefore +incorrectly be considered suitable for a retry operation. + +By using addresses, we ensure that once a server is marked as deprioritized by an operation, it cannot be used again for +a retry on that operation unless there are no other suitable servers. + ## References - [Server Discovery and Monitoring](../server-discovery-and-monitoring/server-discovery-and-monitoring.md) specification @@ -1614,6 +1628,9 @@ maxStalenessSeconds first, then tag_sets, and select Node 2. ## Changelog +- 2025-12-08: Require server deprioritization for all topology types and clarify the order of server candidate + filtering. + - 2015-06-26: Updated single-threaded selection logic with "stale" and serverSelectionTryOnce. - 2015-08-10: Updated single-threaded selection logic to ensure a scan always happens at least once under diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedNearest.json b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedNearest.json new file mode 100644 index 0000000000..f569c39d6c --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedNearest.json @@ -0,0 +1,62 @@ +{ + "topology_description": { + "type": "ReplicaSetNoPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Nearest", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedNearest.yml b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedNearest.yml new file mode 100644 index 0000000000..9297b98a32 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedNearest.yml @@ -0,0 +1,26 @@ +topology_description: + type: ReplicaSetNoPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc +operation: read +read_preference: + mode: Nearest + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimary.json b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimary.json new file mode 100644 index 0000000000..8ec76964e9 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimary.json @@ -0,0 +1,39 @@ +{ + "topology_description": { + "type": "ReplicaSetNoPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Primary" + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [], + "in_latency_window": [] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimary.yml b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimary.yml new file mode 100644 index 0000000000..6d29358f3c --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimary.yml @@ -0,0 +1,22 @@ +topology_description: + type: ReplicaSetNoPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc +operation: read +read_preference: + mode: Primary +deprioritized_servers: +- *1 +suitable_servers: [] +in_latency_window: [] diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimaryPreferred.json b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimaryPreferred.json new file mode 100644 index 0000000000..4ab48d0b66 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimaryPreferred.json @@ -0,0 +1,62 @@ +{ + "topology_description": { + "type": "ReplicaSetNoPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "PrimaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimaryPreferred.yml b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimaryPreferred.yml new file mode 100644 index 0000000000..cb08766a3d --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedPrimaryPreferred.yml @@ -0,0 +1,26 @@ +topology_description: + type: ReplicaSetNoPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc +operation: read +read_preference: + mode: PrimaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondary.json b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondary.json new file mode 100644 index 0000000000..202a277487 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondary.json @@ -0,0 +1,62 @@ +{ + "topology_description": { + "type": "ReplicaSetNoPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Secondary", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondary.yml b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondary.yml new file mode 100644 index 0000000000..08ca00c0ab --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondary.yml @@ -0,0 +1,26 @@ +topology_description: + type: ReplicaSetNoPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc +operation: read +read_preference: + mode: Secondary + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryPreferred.json b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryPreferred.json new file mode 100644 index 0000000000..d37e5545da --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryPreferred.json @@ -0,0 +1,62 @@ +{ + "topology_description": { + "type": "ReplicaSetNoPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "SecondaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryPreferred.yml b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryPreferred.yml new file mode 100644 index 0000000000..0ae92459ae --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetNoPrimary/read/DeprioritizedSecondaryPreferred.yml @@ -0,0 +1,26 @@ +topology_description: + type: ReplicaSetNoPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc +operation: read +read_preference: + mode: SecondaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllPrimaryPreferred.json b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllPrimaryPreferred.json new file mode 100644 index 0000000000..9f415203b3 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllPrimaryPreferred.json @@ -0,0 +1,84 @@ +{ + "topology_description": { + "type": "ReplicaSetWithPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "PrimaryPreferred", + "tag_sets": [ + {} + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllPrimaryPreferred.yml b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllPrimaryPreferred.yml new file mode 100644 index 0000000000..f63605889e --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllPrimaryPreferred.yml @@ -0,0 +1,34 @@ +topology_description: + type: ReplicaSetWithPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &3 + address: a:27017 + avg_rtt_ms: 5 + type: RSPrimary + tags: + data_center: nyc +operation: read +read_preference: + mode: PrimaryPreferred + tag_sets: + - {} +deprioritized_servers: +- *1 +- *2 +- *3 +suitable_servers: +- *3 +in_latency_window: +- *3 diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllSecondaryPreferred.json b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllSecondaryPreferred.json new file mode 100644 index 0000000000..f8d321b067 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllSecondaryPreferred.json @@ -0,0 +1,100 @@ +{ + "topology_description": { + "type": "ReplicaSetWithPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "SecondaryPreferred", + "tag_sets": [ + {} + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllSecondaryPreferred.yml b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllSecondaryPreferred.yml new file mode 100644 index 0000000000..37e9e055ca --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedAllSecondaryPreferred.yml @@ -0,0 +1,36 @@ +topology_description: + type: ReplicaSetWithPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &3 + address: a:27017 + avg_rtt_ms: 5 + type: RSPrimary + tags: + data_center: nyc +operation: read +read_preference: + mode: SecondaryPreferred + tag_sets: + - {} +deprioritized_servers: +- *1 +- *2 +- *3 +suitable_servers: +- *1 +- *2 +in_latency_window: +- *1 +- *2 diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearest.json b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearest.json new file mode 100644 index 0000000000..5b9d0fa538 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearest.json @@ -0,0 +1,78 @@ +{ + "topology_description": { + "type": "ReplicaSetWithPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 26, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Nearest", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 26, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "a:27017", + "avg_rtt_ms": 26, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearest.yml b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearest.yml new file mode 100644 index 0000000000..3dcb9bffdc --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedNearest.yml @@ -0,0 +1,33 @@ +topology_description: + type: ReplicaSetWithPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc + - &3 + address: a:27017 + avg_rtt_ms: 26 + type: RSPrimary + tags: + data_center: nyc +operation: read +read_preference: + mode: Nearest + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *3 +- *2 +in_latency_window: +- *3 diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimary.json b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimary.json new file mode 100644 index 0000000000..a1ef5b200f --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimary.json @@ -0,0 +1,65 @@ +{ + "topology_description": { + "type": "ReplicaSetWithPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Primary" + }, + "deprioritized_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimary.yml b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimary.yml new file mode 100644 index 0000000000..a4c09ba3d4 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimary.yml @@ -0,0 +1,30 @@ +topology_description: + type: ReplicaSetWithPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &3 + address: a:27017 + avg_rtt_ms: 5 + type: RSPrimary + tags: + data_center: nyc +operation: read +read_preference: + mode: Primary +deprioritized_servers: +- *3 +suitable_servers: +- *3 +in_latency_window: +- *3 diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimaryPreferred.json b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimaryPreferred.json new file mode 100644 index 0000000000..7b6da395c5 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimaryPreferred.json @@ -0,0 +1,84 @@ +{ + "topology_description": { + "type": "ReplicaSetWithPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "PrimaryPreferred", + "tag_sets": [ + {} + ] + }, + "deprioritized_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimaryPreferred.yml b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimaryPreferred.yml new file mode 100644 index 0000000000..83551a51bb --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedPrimaryPreferred.yml @@ -0,0 +1,34 @@ +topology_description: + type: ReplicaSetWithPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &3 + address: a:27017 + avg_rtt_ms: 5 + type: RSPrimary + tags: + data_center: nyc +operation: read +read_preference: + mode: PrimaryPreferred + tag_sets: + - {} +deprioritized_servers: +- *3 +suitable_servers: +- *1 +- *2 +in_latency_window: +- *1 +- *2 diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondary.json b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondary.json new file mode 100644 index 0000000000..f3dc03db09 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondary.json @@ -0,0 +1,86 @@ +{ + "topology_description": { + "type": "ReplicaSetWithPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 26, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Secondary", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondary.yml b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondary.yml new file mode 100644 index 0000000000..cfcedf3a57 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondary.yml @@ -0,0 +1,34 @@ +topology_description: + type: ReplicaSetWithPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc + - &3 + address: a:27017 + avg_rtt_ms: 26 + type: RSPrimary + tags: + data_center: nyc +operation: read +read_preference: + mode: Secondary + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +- *2 +suitable_servers: +- *1 +- *2 +in_latency_window: +- *1 diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryPreferred.json b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryPreferred.json new file mode 100644 index 0000000000..1fd6c654f0 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryPreferred.json @@ -0,0 +1,78 @@ +{ + "topology_description": { + "type": "ReplicaSetWithPrimary", + "servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "SecondaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryPreferred.yml b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryPreferred.yml new file mode 100644 index 0000000000..1db29405f9 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/read/DeprioritizedSecondaryPreferred.yml @@ -0,0 +1,33 @@ +topology_description: + type: ReplicaSetWithPrimary + servers: + - &1 + address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - &2 + address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc + - &3 + address: a:27017 + avg_rtt_ms: 5 + type: RSPrimary + tags: + data_center: nyc +operation: read +read_preference: + mode: SecondaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +- *2 +suitable_servers: +- *3 +in_latency_window: +- *3 diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/write/DeprioritizedSecondaryPreferred.json b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/write/DeprioritizedSecondaryPreferred.json new file mode 100644 index 0000000000..4669ee57d5 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/write/DeprioritizedSecondaryPreferred.json @@ -0,0 +1,70 @@ +{ + "topology_description": { + "type": "ReplicaSetWithPrimary", + "servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 26, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "b:27017", + "avg_rtt_ms": 5, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + }, + { + "address": "c:27017", + "avg_rtt_ms": 100, + "type": "RSSecondary", + "tags": { + "data_center": "nyc" + } + } + ] + }, + "operation": "write", + "read_preference": { + "mode": "SecondaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 26, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "suitable_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 26, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ], + "in_latency_window": [ + { + "address": "a:27017", + "avg_rtt_ms": 26, + "type": "RSPrimary", + "tags": { + "data_center": "nyc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/write/DeprioritizedSecondaryPreferred.yml b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/write/DeprioritizedSecondaryPreferred.yml new file mode 100644 index 0000000000..71521cee62 --- /dev/null +++ b/source/server-selection/tests/server_selection/ReplicaSetWithPrimary/write/DeprioritizedSecondaryPreferred.yml @@ -0,0 +1,30 @@ +topology_description: + type: ReplicaSetWithPrimary + servers: + - &1 + address: a:27017 + avg_rtt_ms: 26 + type: RSPrimary + tags: + data_center: nyc + - address: b:27017 + avg_rtt_ms: 5 + type: RSSecondary + tags: + data_center: nyc + - address: c:27017 + avg_rtt_ms: 100 + type: RSSecondary + tags: + data_center: nyc +operation: write +read_preference: + mode: SecondaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *1 +in_latency_window: +- *1 diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedNearest.json b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedNearest.json new file mode 100644 index 0000000000..1aa730cd21 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedNearest.json @@ -0,0 +1,47 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 10, + "type": "Mongos" + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Nearest", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 10, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 10, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedNearest.yml b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedNearest.yml new file mode 100644 index 0000000000..27fd8fc693 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedNearest.yml @@ -0,0 +1,22 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 10 + type: Mongos +operation: read +read_preference: + mode: Nearest + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimary.json b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimary.json new file mode 100644 index 0000000000..8629c84a2b --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimary.json @@ -0,0 +1,42 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Primary" + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimary.yml b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimary.yml new file mode 100644 index 0000000000..a7bfee07d8 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimary.yml @@ -0,0 +1,20 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 5 + type: Mongos +operation: read +read_preference: + mode: Primary +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimaryPreferred.json b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimaryPreferred.json new file mode 100644 index 0000000000..800264cfde --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimaryPreferred.json @@ -0,0 +1,47 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "PrimaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimaryPreferred.yml b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimaryPreferred.yml new file mode 100644 index 0000000000..3452acdeff --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedPrimaryPreferred.yml @@ -0,0 +1,22 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 5 + type: Mongos +operation: read +read_preference: + mode: PrimaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondary.json b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondary.json new file mode 100644 index 0000000000..42d1e227f1 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondary.json @@ -0,0 +1,47 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "Secondary", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondary.yml b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondary.yml new file mode 100644 index 0000000000..5db7667238 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondary.yml @@ -0,0 +1,22 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 5 + type: Mongos +operation: read +read_preference: + mode: Secondary + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondaryPreferred.json b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondaryPreferred.json new file mode 100644 index 0000000000..eaab0b3af5 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondaryPreferred.json @@ -0,0 +1,47 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "SecondaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondaryPreferred.yml b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondaryPreferred.yml new file mode 100644 index 0000000000..a07e44b55f --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/read/DeprioritizedSecondaryPreferred.yml @@ -0,0 +1,22 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 5 + type: Mongos +operation: read +read_preference: + mode: SecondaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedNearest.json b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedNearest.json new file mode 100644 index 0000000000..5cc2cc5477 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedNearest.json @@ -0,0 +1,47 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 10, + "type": "Mongos" + } + ] + }, + "operation": "write", + "read_preference": { + "mode": "Nearest", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 10, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 10, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedNearest.yml b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedNearest.yml new file mode 100644 index 0000000000..af8ca190d6 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedNearest.yml @@ -0,0 +1,22 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 10 + type: Mongos +operation: write +read_preference: + mode: Nearest + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimary.json b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimary.json new file mode 100644 index 0000000000..a936658939 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimary.json @@ -0,0 +1,42 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] + }, + "operation": "write", + "read_preference": { + "mode": "Primary" + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimary.yml b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimary.yml new file mode 100644 index 0000000000..7fc405c3f2 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimary.yml @@ -0,0 +1,20 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 5 + type: Mongos +operation: write +read_preference: + mode: Primary +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimaryPreferred.json b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimaryPreferred.json new file mode 100644 index 0000000000..5dc3fa292d --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimaryPreferred.json @@ -0,0 +1,47 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] + }, + "operation": "write", + "read_preference": { + "mode": "PrimaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimaryPreferred.yml b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimaryPreferred.yml new file mode 100644 index 0000000000..cf2359cc44 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedPrimaryPreferred.yml @@ -0,0 +1,22 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 5 + type: Mongos +operation: write +read_preference: + mode: PrimaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondary.json b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondary.json new file mode 100644 index 0000000000..8b5cc5251c --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondary.json @@ -0,0 +1,47 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] + }, + "operation": "write", + "read_preference": { + "mode": "Secondary", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondary.yml b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondary.yml new file mode 100644 index 0000000000..06888b0bb7 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondary.yml @@ -0,0 +1,22 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 5 + type: Mongos +operation: write +read_preference: + mode: Secondary + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondaryPreferred.json b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondaryPreferred.json new file mode 100644 index 0000000000..dcff289cc2 --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondaryPreferred.json @@ -0,0 +1,47 @@ +{ + "topology_description": { + "type": "Sharded", + "servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + }, + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] + }, + "operation": "write", + "read_preference": { + "mode": "SecondaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "g:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "suitable_servers": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ], + "in_latency_window": [ + { + "address": "h:27017", + "avg_rtt_ms": 5, + "type": "Mongos" + } + ] +} diff --git a/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondaryPreferred.yml b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondaryPreferred.yml new file mode 100644 index 0000000000..8c1abf2cec --- /dev/null +++ b/source/server-selection/tests/server_selection/Sharded/write/DeprioritizedSecondaryPreferred.yml @@ -0,0 +1,22 @@ +topology_description: + type: Sharded + servers: + - &1 + address: g:27017 + avg_rtt_ms: 5 + type: Mongos + - &2 + address: h:27017 + avg_rtt_ms: 5 + type: Mongos +operation: write +read_preference: + mode: SecondaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *2 +in_latency_window: +- *2 diff --git a/source/server-selection/tests/server_selection/Single/read/Deprioritized.json b/source/server-selection/tests/server_selection/Single/read/Deprioritized.json new file mode 100644 index 0000000000..c76fc6c771 --- /dev/null +++ b/source/server-selection/tests/server_selection/Single/read/Deprioritized.json @@ -0,0 +1,54 @@ +{ + "topology_description": { + "type": "Single", + "servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "Standalone", + "tags": { + "data_center": "dc" + } + } + ] + }, + "operation": "read", + "read_preference": { + "mode": "SecondaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "Standalone", + "tags": { + "data_center": "dc" + } + } + ], + "suitable_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "Standalone", + "tags": { + "data_center": "dc" + } + } + ], + "in_latency_window": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "Standalone", + "tags": { + "data_center": "dc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/Single/read/Deprioritized.yml b/source/server-selection/tests/server_selection/Single/read/Deprioritized.yml new file mode 100644 index 0000000000..463a7a5535 --- /dev/null +++ b/source/server-selection/tests/server_selection/Single/read/Deprioritized.yml @@ -0,0 +1,20 @@ +topology_description: + type: Single + servers: + - &1 + address: a:27017 + avg_rtt_ms: 5 + type: Standalone + tags: + data_center: dc +operation: read +read_preference: + mode: SecondaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *1 +in_latency_window: +- *1 diff --git a/source/server-selection/tests/server_selection/Single/write/Deprioritized.json b/source/server-selection/tests/server_selection/Single/write/Deprioritized.json new file mode 100644 index 0000000000..099076f2da --- /dev/null +++ b/source/server-selection/tests/server_selection/Single/write/Deprioritized.json @@ -0,0 +1,54 @@ +{ + "topology_description": { + "type": "Single", + "servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "Standalone", + "tags": { + "data_center": "dc" + } + } + ] + }, + "operation": "write", + "read_preference": { + "mode": "SecondaryPreferred", + "tag_sets": [ + { + "data_center": "nyc" + } + ] + }, + "deprioritized_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "Standalone", + "tags": { + "data_center": "dc" + } + } + ], + "suitable_servers": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "Standalone", + "tags": { + "data_center": "dc" + } + } + ], + "in_latency_window": [ + { + "address": "a:27017", + "avg_rtt_ms": 5, + "type": "Standalone", + "tags": { + "data_center": "dc" + } + } + ] +} diff --git a/source/server-selection/tests/server_selection/Single/write/Deprioritized.yml b/source/server-selection/tests/server_selection/Single/write/Deprioritized.yml new file mode 100644 index 0000000000..08780151c9 --- /dev/null +++ b/source/server-selection/tests/server_selection/Single/write/Deprioritized.yml @@ -0,0 +1,20 @@ +topology_description: + type: Single + servers: + - &1 + address: a:27017 + avg_rtt_ms: 5 + type: Standalone + tags: + data_center: dc +operation: write +read_preference: + mode: SecondaryPreferred + tag_sets: + - data_center: nyc +deprioritized_servers: +- *1 +suitable_servers: +- *1 +in_latency_window: +- *1