Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Duplicate
-
2.8.0-rc4
-
None
-
None
-
ALL
Description
There are places in the code where we do
if ( strstr(ns, ".system.") )
|
or
if ( ns.find(".system.") != string::npos )
|
to detect system namespaces. Such substring matching is incorrect, since it returns true for namespaces like "db.foo.system.bar", which are not usually considered system namespaces. Matching should be prefix-based, as is now done for writes, for example.
This is along the same lines as SERVER-4558 and SERVER-8814, which refer to specific instances of this.
The cases that seem to be present currently are:
$ ag 'strstr *\(.* *"\.system\."'
|
src/mongo/db/query/get_executor.cpp
|
571: if (strstr(ns, ".system.")) {
|
|
$ ag '\.find *\( *"\.system\."'
|
src/mongo/db/query/get_executor.cpp
|
145: || (string::npos != ns.find(".system."))
|
|
src/mongo/db/ops/insert.cpp
|
188: if ( coll.find( ".system." ) != string::npos ) {
|
|
src/mongo/s/commands_admin.cpp
|
526: if ( ns.find( ".system." ) != string::npos ) {
|
This ticket is to request that these occurrences in the code be updated to use prefix matches, not substring matches. Specifically:
- src/mongo/db/query/get_executor.cpp:571 appears to affect updates.
- src/mongo/db/query/get_executor.cpp:145 affects the behaviour of --notablescan, in that table scans may erroneously be permitted on collections that happen to contain an embedded ".system.".
- src/mongo/db/ops/insert.cpp:188 should be dropped completely, since it is just for backwards compatibility and the earlier code block at line 168 better handles system namespace detection.
- s/commands_admin.cpp:526 affects the ability to shard collections that happen to contain an embedded ".system.".
Probably somewhere there should be single isSystemNamespace()/isSystemCollection() function(s) for doing this detection consistently.
Attachments
Issue Links
- duplicates
-
SERVER-4558 namespace validation on insert uses substring matching not prefix matching
-
- Backlog
-
- related to
-
SERVER-8814 Inserts into any namespace ending in ".system.indexes" are treated like inserts into "system.indexes" and actually build indexes.
-
- Closed
-