Skip to content

PHPLIB-456: Always invalidate ChangeStream position if iteration fails #674

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
merged 1 commit into from
Aug 29, 2019

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Aug 28, 2019

https://jira.mongodb.org/browse/PHPLIB-456

Contrary to the suggestion in the ticket, the implementation could not happen in MongoDB\ChangeStream. Doing so would've required catching the ResumeTokenException thrown in MongoDB\Model\ChangeStreamIterator and rethrowing it after updating its valid flag. To avoid this, I added the logic to the iterator itself, which now requires the cursor to be valid and also have a valid resume token to be considered valid.

Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

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

Suggestion to add a comment, but LGTM.

@@ -1125,34 +1125,21 @@ public function testResumeTokenNotFoundDoesNotAdvanceKey()
$changeStream->next();
$this->fail('Exception for missing resume token was not thrown');
} catch (ResumeTokenException $e) {
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest leaving a comment in the body of each catch block or a combined comment above try that reminds us that the library will throw a client-side error for server < 4.1.8 and we can rely on a server-side error for >= 4.1.8.

alcaeus added a commit that referenced this pull request Aug 29, 2019
@alcaeus alcaeus merged commit 7f20ffb into mongodb:master Aug 29, 2019
@alcaeus alcaeus deleted the phplib-456 branch August 29, 2019 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants