Details
Description
The $snapshot option doesn't seem to be working in 3.2.
The following Go test case works in every other release, but in 3.2 it breaks with "Error: seen duplicated key: 3". The test consists in exercising a worst case scenario where documents are resized (grown) beyond the padding and thus moved forwards, in reverse order, while doing a forward iteration.
func (s *S) TestFindIterSnapshot(c *C) {
|
session, err := mgo.Dial("localhost:40001")
|
c.Assert(err, IsNil)
|
defer session.Close()
|
|
|
// Insane amounts of logging otherwise due to the
|
// amount of data being shuffled.
|
mgo.SetDebug(false)
|
defer mgo.SetDebug(true)
|
|
|
coll := session.DB("mydb").C("mycoll")
|
|
|
var a [1024000]byte
|
|
|
for n := 0; n < 10; n++ {
|
err := coll.Insert(M{"_id": n, "n": n, "a1": &a})
|
c.Assert(err, IsNil)
|
}
|
|
|
query := coll.Find(M{"n": M{"$gt": -1}}).Batch(2).Prefetch(0)
|
query.Snapshot()
|
iter := query.Iter()
|
|
|
seen := map[int]bool{}
|
result := struct {
|
Id int "_id"
|
}{}
|
for iter.Next(&result) {
|
if len(seen) == 2 {
|
// Grow all entries so that they have to move.
|
// Backwards so that the order is inverted.
|
for n := 10; n >= 0; n-- {
|
_, err := coll.Upsert(M{"_id": n}, M{"$set": M{"a2": &a}})
|
c.Assert(err, IsNil)
|
}
|
}
|
if seen[result.Id] {
|
c.Fatalf("seen duplicated key: %d", result.Id)
|
}
|
seen[result.Id] = true
|
}
|
c.Assert(iter.Close(), IsNil)
|
}
|
Test was performed using the mmapv1 storage engine.
Attachments
Issue Links
- related to
-
SERVER-21563 storage_rocks_index_test is broken
-
- Closed
-
-
SERVER-14703 Snapshot queries can miss records if there are concurrent updates
-
- Closed
-