Skip to content

Commit 37e06bc

Browse files
authored
Merge branch 'development' into bugfix/reenjii-fix-json-timezone
2 parents 1563394 + a3bee14 commit 37e06bc

File tree

3 files changed

+70
-15
lines changed

3 files changed

+70
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ Further PR's (with tests) are welcome, but please maintain backwards compatibili
1717
* Hides SASL warnings ([details](https://github.com/globalsign/mgo/pull/7))
1818
* Improved multi-document transaction performance ([details](https://github.com/globalsign/mgo/pull/10), [more](https://github.com/globalsign/mgo/pull/11))
1919
* Fixes timezone handling ([details](https://github.com/go-mgo/mgo/pull/464))
20+
* Fixes cursor timeouts ([detials](https://jira.mongodb.org/browse/SERVER-24899))
2021

2122
---
2223

2324
### Thanks to
25+
* @BenLubar
2426
* @carter2000
2527
* @cezarsa
2628
* @eaglerayp

session.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,20 +3281,23 @@ func prepareFindOp(socket *mongoSocket, op *queryOp, limit int32) bool {
32813281
}
32823282

32833283
find := findCmd{
3284-
Collection: op.collection[nameDot+1:],
3285-
Filter: op.query,
3286-
Projection: op.selector,
3287-
Sort: op.options.OrderBy,
3288-
Skip: op.skip,
3289-
Limit: limit,
3290-
MaxTimeMS: op.options.MaxTimeMS,
3291-
MaxScan: op.options.MaxScan,
3292-
Hint: op.options.Hint,
3293-
Comment: op.options.Comment,
3294-
Snapshot: op.options.Snapshot,
3295-
OplogReplay: op.flags&flagLogReplay != 0,
3296-
Collation: op.options.Collation,
3297-
ReadConcern: readLevel{level: op.readConcern},
3284+
Collection: op.collection[nameDot+1:],
3285+
Filter: op.query,
3286+
Projection: op.selector,
3287+
Sort: op.options.OrderBy,
3288+
Skip: op.skip,
3289+
Limit: limit,
3290+
MaxTimeMS: op.options.MaxTimeMS,
3291+
MaxScan: op.options.MaxScan,
3292+
Hint: op.options.Hint,
3293+
Comment: op.options.Comment,
3294+
Snapshot: op.options.Snapshot,
3295+
Collation: op.options.Collation,
3296+
Tailable: op.flags&flagTailable != 0,
3297+
AwaitData: op.flags&flagAwaitData != 0,
3298+
OplogReplay: op.flags&flagLogReplay != 0,
3299+
NoCursorTimeout: op.flags&flagNoCursorTimeout != 0,
3300+
ReadConcern: readLevel{level: op.readConcern},
32983301
}
32993302

33003303
if op.limit < 0 {

session_test.go

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,7 @@ func (s *S) TestResumeIter(c *C) {
16731673
c.Assert(len(batch), Equals, 0)
16741674
}
16751675

1676-
var cursorTimeout = flag.Bool("cursor-timeout", false, "Enable cursor timeout test")
1676+
var cursorTimeout = flag.Bool("cursor-timeout", false, "Enable cursor timeout tests")
16771677

16781678
func (s *S) TestFindIterCursorTimeout(c *C) {
16791679
if !*cursorTimeout {
@@ -1717,6 +1717,56 @@ func (s *S) TestFindIterCursorTimeout(c *C) {
17171717
c.Assert(iter.Err(), Equals, mgo.ErrCursor)
17181718
}
17191719

1720+
func (s *S) TestFindIterCursorNoTimeout(c *C) {
1721+
if !*cursorTimeout {
1722+
c.Skip("-cursor-timeout")
1723+
}
1724+
session, err := mgo.Dial("localhost:40001")
1725+
c.Assert(err, IsNil)
1726+
defer session.Close()
1727+
1728+
session.SetCursorTimeout(0)
1729+
1730+
type Doc struct {
1731+
Id int "_id"
1732+
}
1733+
1734+
coll := session.DB("test").C("test")
1735+
coll.Remove(nil)
1736+
for i := 0; i < 100; i++ {
1737+
err = coll.Insert(Doc{i})
1738+
c.Assert(err, IsNil)
1739+
}
1740+
1741+
session.SetBatch(1)
1742+
iter := coll.Find(nil).Iter()
1743+
var doc Doc
1744+
if !iter.Next(&doc) {
1745+
c.Fatalf("iterator failed to return any documents")
1746+
}
1747+
1748+
for i := 10; i > 0; i-- {
1749+
c.Logf("Sleeping... %d minutes to go...", i)
1750+
time.Sleep(1*time.Minute + 2*time.Second)
1751+
}
1752+
1753+
// Drain any existing documents that were fetched.
1754+
if !iter.Next(&doc) {
1755+
c.Fatalf("iterator failed to return previously cached document")
1756+
}
1757+
for i := 1; i < 100; i++ {
1758+
if !iter.Next(&doc) {
1759+
c.Errorf("iterator failed on iteration %d", i)
1760+
break
1761+
}
1762+
}
1763+
if iter.Next(&doc) {
1764+
c.Error("iterator returned more than 100 documents")
1765+
}
1766+
1767+
c.Assert(iter.Err(), IsNil)
1768+
}
1769+
17201770
func (s *S) TestTooManyItemsLimitBug(c *C) {
17211771
if *fast {
17221772
c.Skip("-fast")

0 commit comments

Comments
 (0)