[SERVER-4819] different dup dropping semantics with background vs non background indexing Created: 31/Jan/12  Updated: 31/Jan/12  Resolved: 31/Jan/12

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

Type: Question Priority: Major - P3
Reporter: Aaron Staple Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Non background index build -

{a:[2,3]}

document is partially indexed before being dropped at the end of the index build. As a result,

{a:2}

document is also marked as a dup and dropped.

> c.drop()
true
> c.save( {a:3} );
> c.save( {a:[2,3]} );
> c.save( {a:2} );
> c.ensureIndex( {a:1}, {unique:true,dropDups:true} )
> c.find()
{ "_id" : ObjectId("4f277e3e2e17f5bc7039cd20"), "a" : 3 }

Background index build -

{a:[2,3]}

document is dropped as soon as indexing is attempted, as a result

{a:2}

gets inserted.

> c.drop()
true
> c.save( {a:3} );
> c.save( {a:[2,3]} );
> c.save( {a:2} );
> c.ensureIndex( {a:1}, {unique:true,dropDups:true,background:true} )
> c.find()
{ "_id" : ObjectId("4f277e782e17f5bc7039cd24"), "a" : 3 }
{ "_id" : ObjectId("4f277e7d2e17f5bc7039cd26"), "a" : 2 }



 Comments   
Comment by Aaron Staple [ 31/Jan/12 ]

The issue isn't just ordering, but dependencies between documents. With background:true, and the above documents, there will a values of 2 and 3 in the index for any document ordering. For background:false one of 2 or 3 may not be in the index depending on ordering.

This may be fine behavior to have, but we might want to make it explicit when we document what dropDups does.

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

the order of dropDups is not guaranteed

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