Skip to content

Commit

Permalink
Merge branch 'development' into bugfix/reenjii-fix-json-timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
domodwyer authored Jul 5, 2017
2 parents 1563394 + a3bee14 commit 37e06bc
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ Further PR's (with tests) are welcome, but please maintain backwards compatibili
* Hides SASL warnings ([details](https://github.com/globalsign/mgo/pull/7))
* Improved multi-document transaction performance ([details](https://github.com/globalsign/mgo/pull/10), [more](https://github.com/globalsign/mgo/pull/11))
* Fixes timezone handling ([details](https://github.com/go-mgo/mgo/pull/464))
* Fixes cursor timeouts ([detials](https://jira.mongodb.org/browse/SERVER-24899))

---

### Thanks to
* @BenLubar
* @carter2000
* @cezarsa
* @eaglerayp
Expand Down
31 changes: 17 additions & 14 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -3281,20 +3281,23 @@ func prepareFindOp(socket *mongoSocket, op *queryOp, limit int32) bool {
}

find := findCmd{
Collection: op.collection[nameDot+1:],
Filter: op.query,
Projection: op.selector,
Sort: op.options.OrderBy,
Skip: op.skip,
Limit: limit,
MaxTimeMS: op.options.MaxTimeMS,
MaxScan: op.options.MaxScan,
Hint: op.options.Hint,
Comment: op.options.Comment,
Snapshot: op.options.Snapshot,
OplogReplay: op.flags&flagLogReplay != 0,
Collation: op.options.Collation,
ReadConcern: readLevel{level: op.readConcern},
Collection: op.collection[nameDot+1:],
Filter: op.query,
Projection: op.selector,
Sort: op.options.OrderBy,
Skip: op.skip,
Limit: limit,
MaxTimeMS: op.options.MaxTimeMS,
MaxScan: op.options.MaxScan,
Hint: op.options.Hint,
Comment: op.options.Comment,
Snapshot: op.options.Snapshot,
Collation: op.options.Collation,
Tailable: op.flags&flagTailable != 0,
AwaitData: op.flags&flagAwaitData != 0,
OplogReplay: op.flags&flagLogReplay != 0,
NoCursorTimeout: op.flags&flagNoCursorTimeout != 0,
ReadConcern: readLevel{level: op.readConcern},
}

if op.limit < 0 {
Expand Down
52 changes: 51 additions & 1 deletion session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1673,7 +1673,7 @@ func (s *S) TestResumeIter(c *C) {
c.Assert(len(batch), Equals, 0)
}

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

func (s *S) TestFindIterCursorTimeout(c *C) {
if !*cursorTimeout {
Expand Down Expand Up @@ -1717,6 +1717,56 @@ func (s *S) TestFindIterCursorTimeout(c *C) {
c.Assert(iter.Err(), Equals, mgo.ErrCursor)
}

func (s *S) TestFindIterCursorNoTimeout(c *C) {
if !*cursorTimeout {
c.Skip("-cursor-timeout")
}
session, err := mgo.Dial("localhost:40001")
c.Assert(err, IsNil)
defer session.Close()

session.SetCursorTimeout(0)

type Doc struct {
Id int "_id"
}

coll := session.DB("test").C("test")
coll.Remove(nil)
for i := 0; i < 100; i++ {
err = coll.Insert(Doc{i})
c.Assert(err, IsNil)
}

session.SetBatch(1)
iter := coll.Find(nil).Iter()
var doc Doc
if !iter.Next(&doc) {
c.Fatalf("iterator failed to return any documents")
}

for i := 10; i > 0; i-- {
c.Logf("Sleeping... %d minutes to go...", i)
time.Sleep(1*time.Minute + 2*time.Second)
}

// Drain any existing documents that were fetched.
if !iter.Next(&doc) {
c.Fatalf("iterator failed to return previously cached document")
}
for i := 1; i < 100; i++ {
if !iter.Next(&doc) {
c.Errorf("iterator failed on iteration %d", i)
break
}
}
if iter.Next(&doc) {
c.Error("iterator returned more than 100 documents")
}

c.Assert(iter.Err(), IsNil)
}

func (s *S) TestTooManyItemsLimitBug(c *C) {
if *fast {
c.Skip("-fast")
Expand Down

0 comments on commit 37e06bc

Please sign in to comment.