Skip to content

GODRIVER-3473 Short-cicruit cursor.next() on invalid timeouts #2135

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 5 commits into from
Aug 1, 2025

Conversation

prestonvasquez
Copy link
Member

@prestonvasquez prestonvasquez commented Jul 22, 2025

GODRIVER-3473

Summary

Short-circuit calls to cursor.Next() where maxAwaitTimeMS >= operation timeout, which would result in socket timeouts.

Background & Motivation

The specifications assume that drivers iteratively apply the timeout provided at the constructor level (e.g., (*collection).Find) for tailable awaitData cursors:

If set, drivers MUST apply the timeoutMS option to the initial aggregate operation. Drivers MUST also apply the original timeoutMS value to each next call on the change stream but MUST NOT use it to derive a maxTimeMS field for getMore commands.

The Go Driver might decide to support the above behavior with DRIVERS-2722. The principal concern is that it would be unexpected for users to apply an operation-level timeout via contexts to a constructor and then have that timeout later be applied while working with a resulting cursor. Instead, it is more idiomatic to apply the timeout to the context passed to Next or TryNext.

@mongodb-drivers-pr-bot mongodb-drivers-pr-bot bot added the review-priority-low Low Priority PR for Review: within 3 business days label Jul 22, 2025
Copy link
Contributor

mongodb-drivers-pr-bot bot commented Jul 22, 2025

API Change Report

./v2/x/mongo/driver

compatible changes

(*BatchCursor).MaxAwaitTime: added

@prestonvasquez prestonvasquez marked this pull request as ready for review July 23, 2025 17:27
@prestonvasquez prestonvasquez requested a review from a team as a code owner July 23, 2025 17:27
@prestonvasquez prestonvasquez requested review from qingyang-hu and matthewdale and removed request for qingyang-hu July 23, 2025 17:27
@prestonvasquez prestonvasquez force-pushed the GODRIVER-3473 branch 3 times, most recently from dc35fae to eb14ddf Compare July 31, 2025 21:40
Copy link
Collaborator

@matthewdale matthewdale left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

@prestonvasquez prestonvasquez merged commit 724d9e4 into mongodb:master Aug 1, 2025
32 of 34 checks passed
@prestonvasquez prestonvasquez deleted the GODRIVER-3473 branch August 1, 2025 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review-priority-low Low Priority PR for Review: within 3 business days
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants