[SERVER-59821] Time-series collections can only remove documents whose _id is an ObjectId Created: 07/Sep/21  Updated: 17/Apr/23

Status: Open
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Josef Ahmad Assignee: Backlog - Storage Execution Team
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Operating System: ALL
Steps To Reproduce:

> db.createCollection('system.buckets.c', {clusteredIndex: true})
> db.system.buckets.c.insertOne({_id:1})
{ "acknowledged" : true, "insertedId" : 1 }
> db.system.buckets.c.remove({_id:1})
WriteResult({WriteResult({ "nRemoved" : 0, "writeError" : { "code" : 13111, "errmsg" : "wrong type for field (_id) double != objectId" }})

Participants:

 Description   

On clustered collections, the remove path seems to assume that the _id of a document is always an ObjectId.



 Comments   
Comment by Haley Connelly [ 29/Sep/21 ]

josef.ahmad
For what it's worth, remove does work, just not on a buckets collection it seems.

I made the following changes to confirm this is a non-issue for other types of clustered collections

diff --git a/jstests/core/clustered_index_creation.js b/jstests/core/clustered_index_creation.js
index df98c629be..6d62c62692 100644
--- a/jstests/core/clustered_index_creation.js
+++ b/jstests/core/clustered_index_creation.js
@@ -48,6 +48,12 @@ const validateListCollections = function(db, collName, creationOptions) {
  */
 const runSuccessfulCreate = function(db, coll, creationOptions) {
     assert.commandWorked(db.createCollection(coll.getName(), creationOptions));
+
+    assert.commandWorked(coll.insert({_id: 1}));
+    assert.eq(coll.find({_id: 1}).itcount(), 1);
+    assert.commandWorked(coll.remove({_id: 1}));
+    assert.eq(coll.find({_id: 1}).itcount(), 0);
+
     validateListCollections(testDB, coll.getName(), creationOptions);
     coll.drop();
 };

I think the question is- do we want to restrict users from inserting into system.buckets collections altogether/ is there a ticket for this? 

Otherwise, this ticket can be changed to specify the issue is only for timeseries / buckets collections

Comment by Louis Williams [ 28/Sep/21 ]

We should add a lot more testing for basic crud ops here.

Generated at Thu Feb 08 05:48:12 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.