Skip to content

Commit

Permalink
tweak batch size for long running reads to prevent cursor timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
rwynn committed Jul 9, 2019
1 parent 7d164ba commit 4e47779
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions gtm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1091,12 +1091,11 @@ func DirectReadSegment(ctx *OpCtx, session *mgo.Session, ns string, options *Opt
ctx.ErrC <- errors.Wrap(err, "Error starting direct reads. Invalid namespace.")
return
}
var batch int64 = 1000
var batch int64 = 500
if stats.AvgObjectSize != 0 {
batch = (8 * 1024 * 1024) / stats.AvgObjectSize // 8MB divided by avg doc size
if batch < 1000 {
// leave it up to the server
batch = 0
batch = (2 * 1024 * 1024) / stats.AvgObjectSize // 2MB divided by avg doc size
if batch < 500 {
batch = 500
}
}
restart:
Expand Down

0 comments on commit 4e47779

Please sign in to comment.