Skip to content

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 matthewdale and qingyang-hu 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
alcaeus added a commit that referenced this pull request Aug 5, 2025
* master: (65 commits)
  Replace all uses of 'interface{}' with 'any' in the bson package. (#2138)
  GODRIVER-3473 Short-cicruit cursor.next() on invalid timeouts (#2135)
  GODRIVER-3622 Automatically retry some test tasks. (#2147)
  Replace all uses of 'interface{}' with 'any' in the repo docs. (#2142)
  GODRIVER-3102: Perf comparison (#2134)
  GODRIVER-3587 Use raw bytes in valueReader (#2120)
  Replace all uses of 'interface{}' with 'any' in the internal/ packages. (#2140)
  Replace all uses of 'interface{}' with 'any' in the x/ packages. (#2137)
  GODRIVER-2016 Unskip all Transactions unified spec tests. (#2132)
  GODRIVER-2540 Run govulncheck in CI builds. (#2136)
  GODRIVER-3549 Update Client BulkWrite prose tests. (#2131)
  Add guidelines for contributing features to the Go Driver (#2125)
  Bump alcaeus/automatic-merge-up-action from 1.0.0 to 1.0.1 in the actions group (#2126)
  Add wrappedMsgOnly to mongo.MarshalError and mongo.MongocryptError.
  Bump testdata/specifications from `db69351` to `6689929`
  fix wiremessage oob in case of intmin (#2076)
  GODRIVER-3399: PoolClearedError should have TransientTransactionError label appended to it (#2114)
  PR feedback.
  Prevent integration tests from running when testing with -short
  Skip AWS Test if no URI (#2102)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 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