[SERVER-12993] Insert write command creates db and collection on invalid input Created: 03/Mar/14  Updated: 02/Jun/22  Resolved: 10/Mar/14

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.6.0-rc0
Fix Version/s: 2.6.0-rc2

Type: Bug Priority: Minor - P4
Reporter: Mathias Stearn Assignee: Greg Studer
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
related to SERVER-66964 remove insert2.js Closed
is related to SERVER-12994 Invalid queries accepted by delete co... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Participants:
Linked BF Score: 0

 Description   

Legacy insert does not:

> use newdb
switched to db newdb
> db.dropDatabase()
{ "dropped" : "newdb", "ok" : 1 }
> db.stats()
{
        "db" : "newdb",
        "collections" : 0,
        "objects" : 0,
        "avgObjSize" : 0,
        "dataSize" : 0,
        "storageSize" : 0,
        "numExtents" : 0,
        "indexes" : 0,
        "indexSize" : 0,
        "fileSize" : 0,
        "dataFileVersion" : {
 
        },
        "ok" : 1
}
> db.getMongo().insert('newdb.foo', {$notAllowed: true}, 0);
> db.stats()
{
        "db" : "newdb",
        "collections" : 0,
        "objects" : 0,
        "avgObjSize" : 0,
        "dataSize" : 0,
        "storageSize" : 0,
        "numExtents" : 0,
        "indexes" : 0,
        "indexSize" : 0,
        "fileSize" : 0,
        "dataFileVersion" : {
 
        },
        "ok" : 1
}
> db.foo.runCommand('insert', {documents: [{$notAllowed: true}]})
{
        "ok" : 1,
        "n" : 0,
        "writeErrors" : [
                {
                        "index" : 0,
                        "code" : 2,
                        "errmsg" : "Document can't have $ prefixed field names: $notAllowed"
                }
        ]
}
> db.stats()
{
        "db" : "newdb",
        "collections" : 3,
        "objects" : 4,
        "avgObjSize" : 64,
        "dataSize" : 256,
        "storageSize" : 24576,
        "numExtents" : 3,
        "indexes" : 1,
        "indexSize" : 8176,
        "fileSize" : 67108864,
        "nsSizeMB" : 16,
        "dataFileVersion" : {
                "major" : 4,
                "minor" : 5
        },
        "extentFreeList" : {
                "num" : 0,
                "totalSize" : 0
        },
        "ok" : 1
}
> db.foo.stats()
{
        "ns" : "newdb.foo",
        "count" : 0,
        "size" : 0,
        "storageSize" : 8192,
        "numExtents" : 1,
        "nindexes" : 1,
        "lastExtentSize" : 8192,
        "paddingFactor" : 1,
        "systemFlags" : 1,
        "userFlags" : 1,
        "totalIndexSize" : 8176,
        "indexSizes" : {
                "_id_" : 8176
        },
        "ok" : 1
}



 Comments   
Comment by Githook User [ 14/Mar/14 ]

Author:

{u'username': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-12993 restore batch_write_insert test behavior to be exacting
Branch: v2.6
https://github.com/mongodb/mongo/commit/0716e47f14526def38c4190e91dde6a1d516a81b

Comment by Githook User [ 14/Mar/14 ]

Author:

{u'username': u'milkie', u'name': u'Eric Milkie', u'email': u'milkie@10gen.com'}

Message: SERVER-12993 restore batch_write_insert test behavior to be exacting
Branch: master
https://github.com/mongodb/mongo/commit/b83a8b935ac6fc34dffa42202dc22b122d65e02e

Comment by Githook User [ 10/Mar/14 ]

Author:

{u'username': u'gregstuder', u'name': u'Greg Studer', u'email': u'greg@10gen.com'}

Message: SERVER-12993 don't take write lock until a valid insert is detected
Branch: master
https://github.com/mongodb/mongo/commit/6311297efc74ee70ff2b01af5ebb25537587f9cf

Comment by Scott Hernandez (Inactive) [ 04/Mar/14 ]

NOTE: When this fix goes in please also revert (and add more checking) to the altered tests here: https://github.com/mongodb/mongo/commit/c9794d1885cf1e847b9543912287acc41909dfab

Comment by Githook User [ 04/Mar/14 ]

Author:

{u'username': u'scotthernandez', u'name': u'Scott Hernandez', u'email': u'scotthernandez@gmail.com'}

Message: SERVER-12993: drop db in test until fixed
Branch: master
https://github.com/mongodb/mongo/commit/c9794d1885cf1e847b9543912287acc41909dfab

Generated at Thu Feb 08 03:30:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.