[SERVER-5604] update fails silently when notablescans=true Created: 14/Apr/12  Updated: 09/Jul/16  Resolved: 10/Oct/12

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

Type: Bug Priority: Minor - P4
Reporter: Nic Cottrell (Personal) Assignee: Scott Hernandez (Inactive)
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

RHEL5


Operating System: Linux
Participants:

 Description   

I have

  • notablescans=true in mongod.conf
  • sparse index on {cl:1, lc:1}
  • index on {clExists:1}

Running on the console, neither:

  • db.Example.update({clExists:{$exists:false}, cl: {$exists:false}}, {$set : { clExists: false}});
  • db.Example.update({clExists:{$exists:false}}, {$set : { clExists: false}});
    gives no output but exits very quickly

Running:

  • db.Example.find({clExists:{$exists:false}, cl:{$exists:false}}).limit(10).forEach(printjson);
    gives "table scans not allowed:jerome5.Example"


 Comments   
Comment by Scott Hernandez (Inactive) [ 14/May/12 ]

yeah, I think you are seeing the behavior of a sparse index interacting poorly with the query.

Can you do the update and check the results right after like I do on the second line?

db.Example.find({clExists:{$exists:false}, cl: {$exists:false}}).explain();
db.Example.update({clExists:{$exists:false}, cl: {$exists:false}}, {$set : { clExists: false}});db.getLastErrorObj();

If you have an example script to create the docs/index and do the query/update that would be helpful.

Here is a sample I tested with, let me know if this looks the same as yours.

> db.sparse1.insert({a:1})
> db.sparse1.insert({a:1, b:1})
> db.sparse1.ensureIndex({b:1}, {sparse:true, background:true})
> db.sparse1.find({b:{$exists:false}})
> db.sparse1.find({b:{$exists:false}, a:1}).explain()
{
        "cursor" : "BtreeCursor b_1",
        "isMultiKey" : false,
        "n" : 0, ...}
> db.sparse1.find({a:1})
{ "_id" : ObjectId("4fb18da4b7a636b0337baa85"), "a" : 1 }
{ "_id" : ObjectId("4fb18dd0b7a636b0337baa87"), "a" : 1, "b" : 1 }

Comment by Nic Cottrell (Personal) [ 14/Apr/12 ]

Yeah, I have several multi-key sparse indexes. According to my notes, I created it like:

db.Example.ensureIndex(

{cl:1, l:1}

,

{sparse: true, background:true}

);
db.Unit.ensureIndex(

{sw:1,numeric:1}

,

{sparse:true,background:true}

);

Maybe the background flag is letting it slip through.

Comment by Scott Hernandez (Inactive) [ 14/Apr/12 ]

Yes, when you search for $exists:false with a sparse index the results are not what is generally expected since the sparse index can't return docs which aren't in the index : SERVER-3918

There are also some cases where notablescan does not cause an error : SERVER-2222

Can you post how you created the index? Sparse indexes are currently limited to 1 field so you shouldn't be able to create a sparse index with a compound key. SERVER-2193 – This looks like another bug since you could.

Comment by Nic Cottrell (Personal) [ 14/Apr/12 ]

Update: restarted with notablescan disabled...

This returns results:
db.Example.find({clExists:{$exists:false}, cl:{$exists:false}}).limit(10).forEach(printjson);

But this makes no updates/changes, and just exits after less than a second:
db.Example.update({clExists:{$exists:false}, cl: {$exists:false}}, {$set : { clExists: false}});

Is this a logic error due to the sparse index?

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