Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PHPLIB-322: Add resume logic to ChangeStream::rewind() #479

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

Merged
kvwalker merged 3 commits into mongodb:master from kvwalker:PHPLIB-322
Feb 5, 2018

Conversation

@kvwalker
Copy link
Contributor

@kvwalker kvwalker commented Feb 5, 2018

$resumable = true;
}
if ($e->getCode() === self::CURSOR_NOT_FOUND) {
$resumable = true;
Copy link
Member

@jmikola jmikola Feb 5, 2018

Choose a reason for hiding this comment

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

Extra space for indentation.

$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), $pipeline, ['maxAwaitTimeMS' => 100]);
$changeStream = $operation->execute($this->getPrimaryServer());

$changeStream->rewind();
Copy link
Member

@jmikola jmikola Feb 5, 2018

Choose a reason for hiding this comment

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

I assume this was removed because rewind() now throws its own exception and would prevent us from testing next()

I'd suggest replacing with:

/* Note: we intentionally do not start iteration with rewind() to ensure
 * that we test extraction functionality within next(). */

Borrowed from the socket exception test.

Copy link
Member

@jmikola jmikola Feb 5, 2018

Choose a reason for hiding this comment

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

Side thought: does this actually throw or does it only introduce a delay with its own getMore? Since we've yet to insert a document, I'd expect rewind() to not find any result to attempt extraction.

Copy link
Contributor Author

@kvwalker kvwalker Feb 5, 2018

Choose a reason for hiding this comment

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

You're right, the rewind() doesn't throw because it doesn't attempt extraction.

Copy link
Member

@jmikola jmikola Feb 5, 2018

Choose a reason for hiding this comment

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

This now makes for very amusing diff output.

jmikola reacted with laugh emoji
$this->assertNull($changeStream->current());
}

public function testResumeAfterKillThenOperation()
Copy link
Member

@jmikola jmikola Feb 5, 2018

Choose a reason for hiding this comment

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

testRewindExtractsResumeTokenAndNextResumes()

$this->assertTrue($changeStream->valid());
}

public function testResumeAfterKillThenNoOperations()
Copy link
Member

@jmikola jmikola Feb 5, 2018

Choose a reason for hiding this comment

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

testRewindResumesAfterCursorNotFound()

$operation = new Watch($this->manager, $this->getDatabaseName(), $this->getCollectionName(), [], ['maxAwaitTimeMS' => 100]);
$changeStream = $operation->execute($this->getPrimaryServer());

$this->insertDocument(['_id' => 1, 'x' => 'foo']);
Copy link
Member

@jmikola jmikola Feb 5, 2018

Choose a reason for hiding this comment

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

I think we can simply omit this line. Asserting that rewind() doesn't throw an exception is enough to test that it can resume after not finding a cursor.

Copy link
Member

@jmikola jmikola Feb 5, 2018

Choose a reason for hiding this comment

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

This comment was resolved. No longer applicable to whatever line this points to.

@kvwalker kvwalker merged commit 42bf825 into mongodb:master Feb 5, 2018
kvwalker added a commit that referenced this pull request Feb 5, 2018
@kvwalker kvwalker deleted the PHPLIB-322 branch February 5, 2018 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jmikola jmikola jmikola approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

AltStyle によって変換されたページ (->オリジナル) /