[SERVER-59829] Allow integers for parameters defined in idl as requiring doubles Created: 07/Sep/21  Updated: 29/Oct/23  Resolved: 15/Sep/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.1.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Kelsey Schubert Assignee: Sara Golemon
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Security 2021-09-20
Participants:

 Description   

For example, if I want to disable mirrored reads, I'd like to execute the following command in mongosh:

db.adminCommand( {
  setParameter: 1,
  mirrorReads: { samplingRate: 0 }
} )

However, this will lead to an error since the sampling rate is not a double.

https://github.com/mongodb/mongo/blob/5bbadc66ed462aed3cc4f5635c5003da6171c25d/src/mongo/db/mirror_maestro.idl#L44



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 15/Sep/21 ]

Author:

{'name': 'Sara Golemon', 'email': 'sara.golemon@mongodb.com', 'username': 'sgolemon'}

Message: SERVER-59829 Allow mirrorReads set param to accept coercible numbers as arguments
Branch: master
https://github.com/mongodb/mongo/commit/f5c55aa3b0ef4cafc3de4b5623a9ba467717048f

Comment by Sara Golemon [ 15/Sep/21 ]

The generalized handling in IDL server parameters actually handles loose coersion correctly already when it's a simple scalar value.

Structured values (like mirrorReads) depend on how they're defined individually as structs.

So for example here: https://github.com/mongodb/mongo/blob/master/src/mongo/db/mirror_maestro.idl#L44  `samplingRate` is defined as a `double` which requires strict typing, while the behavior you're looking for here (and indeed, what IMO most people expect) is `safeDouble`.

I'll update this IDL definition as part of this ticket, but this is definitely a per-setting issue, not something that can be addressed broadly (there's an implied assumption that if the IDL author picked double over safeDouble or int over safeInt then they did so for a reason.

Comment by Kelsey Schubert [ 07/Sep/21 ]

Note that this is more annoying because mongosh silently converts doubles to integers.

Consequently our documentation is incorrect: https://docs.mongodb.com/manual/replication/#enable-disable-support-for-mirrored-reads

Per MONGOSH-602, the correct user action would be to explicitly type-cast in mongosh. Instead of

db.adminCommand({setParameter:1, mirrorReads: {samplingRate: 0.0}})

You would need to execute

db.adminCommand({setParameter:1, mirrorReads: {samplingRate: Double(0.0)})

If this work isn't feasible to prioritize, please file a DOCS ticket to review various parameter pages to ensure that the documented examples work.

Generated at Thu Feb 08 05:48:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.