-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Labels:None
- Adds a new 'metadata' flag to the 'validate' command which only performs validation on the collection metadata. This is to allow users to perform a quick validation to detect invalid index options without scanning all of the documents and indexes.
- 'validate' detects invalid index options and recommends running 'collMod' to remove the invalid index options.
Sample log messages:
2021-09-24T14:43:20.964+00:00 I COMMAND 20514 [conn1] "CMD: validate","attr":
2021-09-24T14:43:20.964+00:00 I STORAGE 5980501 [conn1] "Validation of metadata complete for collection. Problems detected","attr":{"namespace":"test.validate_detects_invalid_index_options","uuid":{"uuid":
}}
- The 'collMod' command can be used to remove the invalid index options for all indexes on the given collection.
Can be executed through:
db.runCommand(
)
Sample log messages:
2021-09-24T14:43:22.309+00:00 I COMMAND 5324200 [conn1] "CMD: collMod","attr":{"cmdObj":{"collMod":"collmod_removes_invalid_index_options"}}
2021-09-24T14:43:22.309+00:00 W INDEX 23878 [conn1] "Removing unknown field from index spec","attr":{"fieldName":"safe","indexSpec":{"v":2,"key":
,"name":"x_1","safe":true,"sparse":true,"force":false}}
2021-09-24T14:43:22.309+00:00 W INDEX 23878 [conn1] "Removing unknown field from index spec","attr":{"fieldName":"force","indexSpec":{"v":2,"key":
,"name":"x_1","safe":true,"sparse":true,"force":false}}
2021-09-24T14:43:22.309+00:00 W INDEX 23878 [conn1] "Removing unknown field from index spec","attr":{"fieldName":"xyz","indexSpec":{"v":2,"key":
,"name":"z_1","xyz":false}}
Description of Linked Ticket
Invalid index options such as "safe" may have been created in the past, before the createIndexes command started validating options more strictly.
In MongoDB 5.0, the listIndexes command more strictly validates index options, and fails when an invalid option is encountered. At this point, the only option is to drop and recreate the index.
This feature request is for the validate command to remove these invalid options as it is validating an index. This would provide a much faster way than recreating the index when fixing an invalid index option.
- backported by
-
DOCS-14842 [BACKPORT] [v5.0] Provide a way to check for and to remove invalid index catalog options
- Closed
- documents
-
SERVER-59805 Provide a way to check for and to remove invalid index catalog options
- Closed