-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Cluster Scalability
-
Service Arch 2020-03-09, Service Arch 2020-03-23, Service Arch 2020-04-06, Service arch 2020-04-20, Service arch 2020-05-04, Service arch 2020-05-18, Service arch 2020-06-01, Service arch 2020-06-15, Service arch 2020-06-29, Service arch 2020-07-13, Service Arch 2020-07-27, Service Arch 2020-08-10, Service Arch 2020-08-24
-
3
While writing the driver spec for hedged reads, we noticed that unsupported read preference options are silently ignored. This can produce unexpected behaviour when a user specifies the hedge option against a non-4.4 server: the option is silently ignored and no read hedging will be performed. For example, this is a read command with hedge option set run against a 4.2 server:
MongoDB Enterprise mongos> db.runCommand({count: 'test', $readPreference: { mode: 'secondary', hedge: {asdf: true} }}) { "shards" : { }, "n" : 0, "ok" : 1, "operationTime" : Timestamp(1581060684, 2), "$clusterTime" : { "clusterTime" : Timestamp(1581060684, 2), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } }
In contrast, the server will return an error document if the hedge document contains an unknown option. The following example was run against a 4.3.3 server:
MongoDB Enterprise mongos> db.runCommand({count: 'test', $readPreference: { mode: 'secondary', hedge: {asdf: true} }}) { "ok" : 0, "errmsg" : "BSON field 'hedge.asdf' is an unknown field.", "code" : 40415, "codeName" : "Location40415", "operationTime" : Timestamp(1581060865, 1), "$clusterTime" : { "clusterTime" : Timestamp(1581060865, 1), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } }
Acceptance criteria:
The server should return an error document when an unknown read preference option is encountered.