BugZero found this defect 60 days ago.
Data sources
All data on this page is proprietary to BugZero® or gathered from public sources
3/20/2024
MongoDB Server
No affected releases provided.
No fixed releases provided.
If you have documents and an index {a: 1}: // Collection: $recordId: 1 -> {_id: 1, a: 1} $recordId: 2 -> {_id: 2 a: 2} $recordId: 3 -> {_id: 3, a: 3} // {a: 1} index: {a: 1} -> $recordId: 1 {a: 2} -> $recordId: 2 {a: 3} -> $recordId: 3 Perform an insert via applyOps: db.runCommand({ applyOps: [ { "op" : "i", "ns" : "test.mycoll", "o" : { "_id" : 34, "a": 34 }, "o2" : { "_id" : 34, }, "rid": NumberLong(1) } ] }) In the collection, we end up overwriting the document. But in the index, we add a new entry! // Collection: $recordId: 1 -> {_id: 34, a: 34} $recordId: 2 -> {_id: 2 a: 2} $recordId: 3 -> {_id: 3, a: 3} // {a: 1} index: {a: 1} -> $recordId: 1 {a: 2} -> $recordId: 2 {a: 3} -> $recordId: 3 {a: 34} -> $recordId: 1 // new entry And if you delete the document with {a: 34}, you'll have a dangling index entry: // Collection: $recordId: 2 -> {_id: 2 a: 2} $recordId: 3 -> {_id: 3, a: 3} // {a: 1} index: {a: 1} -> $recordId: 1 // dangling {a: 2} -> $recordId: 2 {a: 3} -> $recordId: 3