[SERVER-5972] Cannot drop system.js collection Created: 31/May/12  Updated: 02/Sep/22  Resolved: 02/Sep/22

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

Type: Bug Priority: Minor - P4
Reporter: Spencer Brody (Inactive) Assignee: Gregory Noma
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-31216 Mark internal collections in metadata... Closed
Duplicate
is duplicated by TOOLS-114 mongorestore --drop sometimes reports... Closed
Related
is related to SERVER-35301 Cannot insert into system.js collecti... Closed
is related to SERVER-67147 Allow system.profile to be dropped wh... Closed
is related to SERVER-5955 Forbid renaming system collections Closed
is related to SERVER-64491 Reconsider allowing the system.js col... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2022-09-05
Participants:

 Description   

db.system.js.drop()
Thu May 31 11:39:58 uncaught exception: drop failed: {
        "ns" : "test.system.js",
        "errmsg" : "exception: can't drop system ns",
        "code" : 12502,
        "ok" : 0
}



 Comments   
Comment by Githook User [ 02/Sep/22 ]

Author:

{'name': 'Gregory Noma', 'email': 'gregory.noma@gmail.com', 'username': 'gregorynoma'}

Message: SERVER-5972 Allow `system.js` to be dropped
Branch: master
https://github.com/mongodb/mongo/commit/26d222d66fbb97152b283a63f8e6393171c8710f

Comment by Asya Kamsky [ 25/Apr/18 ]

It appears you can drop any system. prefixed collections now (tested 3.6.3).

edit apparently not every collection, so never mind my comment - still need to rename before dropping (at least system.js, etc).

Comment by Roman Kuzmin [ 17/Nov/13 ]

There is a way to drop "system.js". As far as this issue https://jira.mongodb.org/browse/SERVER-5955 is not yet resolved, we can rename "system.js" to something else and then drop the renamed collection.

Comment by Manan S [ 30/Sep/13 ]

Interestingly the system.profile capped collection itself isnt getting replicated. Any idea why?

group:PRIMARY> db.system.profile.count()
28358

group:SECONDARY> db.system.profile.count()
0

Comment by Manan S [ 30/Sep/13 ]

Another strange thing I've noticed is this capped collection if created by any other tool such as rockmongo when you change the size of this collection, the data didnt get replicated over to the secondaries. See this difference between the primary and secondary and there isn't any replication lag because all other normal collections data is good on secondaries.

group:PRIMARY> db.system.profile_rockmongo_bk_52461190e998a.count() 869423

group:SECONDARY> db.system.profile_rockmongo_bk_52461190e998a.count() 0

To give a brief, this system.profile_rockmongo_bk collection was created automatically when the size of this capped collection was changed; so it copied the existing profiler data into this new _bk collection and spun a new system.profile collection for the modified size. But you can only query this _bk collection against Primary but not on secondary even though the show collections would show the name in the listing. Anyone any idea why the data is not being replicated?

Comment by Daniel Pasette (Inactive) [ 29/Sep/13 ]

You should be able to change the size of the profile collection without a backup being created. Sounds like a quirk of rockmongo.

http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/#profiler-overhead

Comment by Manan S [ 27/Sep/13 ]

Yeah I'm facing similar issue if you try to change the size of the system.profile capped collection, it will create a backup of the existing and the new entries will then pour into the fresh system.profile. Now I've several such system.profile_bk_xxx collections that are old and no longer required. But if you try to drop it, it throws an error:

PRIMARY> db.system.profile_rockmongo_bk_52422c217960b.drop()
Fri Sep 27 19:22:24.856 JavaScript execution failed: drop failed: {
"ns" : "group.system.profile_rockmongo_bk_52422c217960b",
"errmsg" : "exception: can't drop system ns",
"code" : 12502,
"ok" : 0
} at src/mongo/shell/collection.js:L383

This needs to be resolved asap.
Thanks.

Comment by Roman Kuzmin [ 01/Jun/12 ]

Yet another argument: according to
http://www.mongodb.org/display/DOCS/Mongo+Metadata
system.profile is droppable. At the same time system.js is not droppable though it is also not needed for the database core in order to function properly. This is not consistent. Users will periodically ask questions. IMHO, it is easier to special case this and to allow dropping just like it is allowed for system.profile

Comment by Roman Kuzmin [ 01/Jun/12 ]

I agree that it is not a very important issue. But it violates the least surprise principle, in the first place. Also, though I do not have example use cases but in theory it is possible that in some cases a user may want to invoke some steps based on the simple fact of availability of this collection. But if it cannot be dropped after creation (even creation by mistake) then such scenarios are not possible or get a bit more complex (e.g. an extra check is needed whether or not system.js contains any data).

Comment by Eliot Horowitz (Inactive) [ 31/May/12 ]

Not sure it makes sense to special case it.

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