Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MGO-160 Set tailable cursor dealine before waiting on any getMores #20

Merged
merged 3 commits into from Nov 8, 2018

Conversation

ShaneHarvey
Copy link

@ShaneHarvey ShaneHarvey requested a review from xdg November 7, 2018 23:59
session.go Outdated
// we should expect more data.
// either there is a getMore running or we will schedule one, set
// the deadline regardless.
if deadline.IsZero() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's subtle interplay between having deadline and having iter.timeout. I suggest protecting this if block with deadline.IsZero && iter.timeout >= 0, then replace line 3842 with if ! deadline.IsZero.

Copy link

@xdg xdg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Have you run mgo's test suite with this change?

// we should expect more data.
// either there is a getMore running or we will schedule one, set
// the deadline regardless.
if iter.timeout >= 0 && deadline.IsZero() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor nitpick, but assuming iter.timeout is usually true and deadline.IsZero is usually false (after the first time through the loop), then reversing the predicate order will shortcut faster.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then it will shortcut slower for the more general case where there is no timeout at all.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd assume a timeout is more common, but it doesn't really matter in the real world.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe timeouts are only set for tailable cursors that's why I think it would be the minority.

Copy link
Author

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm relying on Travis for testing: https://travis-ci.org/10gen/mgo/builds/452479168

Do we test mgo in Evergreen?

Still trying to determine how to reliably trigger this case in a test. Working on it here: https://github.com/ShaneHarvey/mgo/commits/fix-tailable-timeout-test

// we should expect more data.
// either there is a getMore running or we will schedule one, set
// the deadline regardless.
if iter.timeout >= 0 && deadline.IsZero() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then it will shortcut slower for the more general case where there is no timeout at all.

@xdg
Copy link

xdg commented Nov 8, 2018

Travis uses a very old version of mongod.

@ShaneHarvey
Copy link
Author

I added 3.2-4.0 testing to travis: ShaneHarvey@5694f97 and tested in https://travis-ci.org/ShaneHarvey/mgo/builds/452550408.

3.4 and 4.0 fail for strange reasons that I think are unrelated to the timeout change.
On 4.0 there’s lots of c.Assert(err, ErrorMatches, "unauthorized|need to login|not authorized .*")
On 3.4 one createIndex fails with:

    c.Assert(err, IsNil)
... value *mgo.QueryError = &mgo.QueryError{Code:67, Message:"Invalid index specification { name: \"text_number_1\", ns: \"mydb.mycoll\", key: { text_number: 1 }, collation: { locale: \"en\", numericOrdering: true } }; cannot create an index with the 'collation' option and v=1", Assertion:false} ("Invalid index specification { name: \"text_number_1\", ns: \"mydb.mycoll\", key: { text_number: 1 }, collation: { locale: \"en\", numericOrdering: true } }; cannot create an index with the 'collation' option and v=1")

This is the build: https://travis-ci.org/ShaneHarvey/mgo/builds/452550408

I think we should investigate these issues in: #21

@ShaneHarvey ShaneHarvey merged commit 3b7bf48 into 10gen:v2 Nov 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants