[SERVER-30389] Simple and generic way to restrict server parameter values Created: 28/Jul/17 Updated: 07/Jun/18 Resolved: 07/Jun/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Kevin Pulo | Assignee: | DO NOT USE - Backlog - Platform Team |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||
| Description |
|
Many numeric server parameters only make sense with positive values, or non-negative, but this is often not enforced. There may be negative impacts to the server if this is done (either deliberately or accidentally). Part of the problem seems to be that there is no MONGO_EXPORT_SERVER_PARAMETER variant that can enforce simple restrictions on the permitted values. This means enforcing restrictions requires using ExportedServerParameter directly (with a fair amount of boilerplate), or MONGO_INITIALIZER hacks to enforce the restrictions through other means (only works for startup parameters). For the case of numeric parameters, This ticket is to request a simple and easy way of enforcing simple restrictions for the most common cases, eg. min and/or max numeric value, string value from a set of allowed strings, non-empty string. I can imagine a variant of MONGO_EXPORT_SERVER_PARAMETER which takes an extra argument to a "ServerParameterValidator" object (templated for genericism), which ExportedServerParameter then uses in the default validate() method. We could then provide some pre-canned ServerParameterValidators for the commonly-needed restrictions. |
| Comments |
| Comment by Kevin Pulo [ 07/Jun/18 ] |
|
|
| Comment by Kevin Pulo [ 28/Jul/17 ] |
|
I did a quick audit of the numeric parameters in 3.4.6. (And more validation-less parameters are being added with MONGO_EXPORT_SERVER_PARAMETER all the time.) These are the numeric parameters which use MONGO_EXPORT_SERVER_PARAMETER (or a variant) and don't enforce bounds. All of them are either a count, size, duration, or fraction/ratio, and only make sense with non-negative values.
The numeric parameters which don't use MONGO_EXPORT_SERVER_PARAMETER, and also don't seem to enforce bounds:
The numeric parameters which use MONGO_EXPORT_SERVER_PARAMETER but enforce bounds some other way:
The numeric parameters which enforce bounds, without using MONGO_EXPORT_SERVER_PARAMETER:
|