Skip to content

Conversation

prestonvasquez
Copy link
Member

@prestonvasquez prestonvasquez commented Aug 19, 2025

GODRIVER-3616

Summary

Apply client-level timeouts for default ITERATION_MODE for tailable/awaitData cursors.

Background & Motivation

Detailed steps to reproduce the problem?
According to the CSOT specifications, the timeoutMS value must apply to cursor iteration methods such as cursor.Next():

When applying the timeoutMS option to next calls on cursor, drivers MUST ensure it applies to the entire call, not individual commands.

@Copilot Copilot AI review requested due to automatic review settings August 19, 2025 22:18
@prestonvasquez prestonvasquez requested a review from a team as a code owner August 19, 2025 22:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for client-level timeouts with Tailable Await Data (TAD) cursors by implementing a mechanism to apply client-level timeout when no context deadline is set.

  • Adds client timeout handling to cursor operations for better timeout management
  • Implements a functional options pattern for cursor configuration
  • Integrates client timeout from collection to cursor initialization

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
mongo/cursor.go Adds client timeout field and options pattern, implements timeout logic in cursor.next()
mongo/collection.go Passes client timeout to cursor creation
internal/integration/cursor_test.go Adds integration test for client-level timeout behavior with TAD cursors

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@prestonvasquez prestonvasquez marked this pull request as draft August 19, 2025 22:19
Copy link
Contributor

API Change Report

No changes found!

Copy link
Contributor

mongodb-drivers-pr-bot bot commented Aug 19, 2025

🧪 Performance Results

Commit SHA: 5c404fb

There were no significant changes to the performance to report for version 68b86cfcfc0e9b0007f95beb.

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@prestonvasquez prestonvasquez removed the request for review from matthewdale August 19, 2025 22:56
@prestonvasquez prestonvasquez added bug review-priority-low Low Priority PR for Review: within 3 business days labels Aug 20, 2025
@prestonvasquez prestonvasquez changed the title GODRIVER-3616 Inc. client-level timeouts w/ TAD cursors GODRIVER-3616 Apply client-level timeout to tailable cursors Aug 22, 2025
@prestonvasquez prestonvasquez force-pushed the bug/godriver-3616-tad-cursors-to-use-client-timeout branch from 2c15fcd to 4a9229b Compare August 22, 2025 22:14
@prestonvasquez prestonvasquez marked this pull request as ready for review August 22, 2025 22:15
@prestonvasquez prestonvasquez force-pushed the bug/godriver-3616-tad-cursors-to-use-client-timeout branch from 3d2f9d9 to dece3ac Compare August 23, 2025 01:42
Comment on lines +46 to +48
type cursorOptions struct {
clientTimeout time.Duration
hasClientTimeout bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to use a value+bool pair here rather than a pointer like in other options APIs in the Go Driver? Also, is there a generic "optional value" type that we can try using here since it's an unexported API?

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer this solution to avoid referencing the value passed to withCursorOptionClientTimeout:

func withCursorOptionClientTimeout(dur *time.Duration) cursorOption {
	return func(opts *cursorOptions) {
		opts.clientTimeout = dur // Changes to clientTimeout changes dur
	}
}

Taking copy feels kind of awkward:

func withCursorOptionClientTimeout(dur *time.Duration) cursorOption {
	return func(opts *cursorOptions) {
		if dur != nil {
			durCopy := *dur
			opts.clientTimeout = &durCopy
		}
	}
}

Not passing the pointer requires extra setup in the collection methods.

IIRC you have a global solution, if you open a GODRIVER ticket I will add it as a TODO here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Created GODRIVER-3650 to track that suggestion.

@prestonvasquez prestonvasquez force-pushed the bug/godriver-3616-tad-cursors-to-use-client-timeout branch 6 times, most recently from 3bbfbf6 to e866d92 Compare August 30, 2025 00:12
matthewdale
matthewdale previously approved these changes Aug 30, 2025
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 force-pushed the bug/godriver-3616-tad-cursors-to-use-client-timeout branch from 6fa9b35 to 8949cfc Compare September 2, 2025 19:45
@prestonvasquez prestonvasquez changed the base branch from master to release/2.3 September 2, 2025 19:46
@prestonvasquez prestonvasquez force-pushed the bug/godriver-3616-tad-cursors-to-use-client-timeout branch from 8949cfc to 97b830a Compare September 3, 2025 04:43
@prestonvasquez prestonvasquez force-pushed the bug/godriver-3616-tad-cursors-to-use-client-timeout branch 2 times, most recently from b36f082 to 1029688 Compare September 3, 2025 04:51
@prestonvasquez prestonvasquez force-pushed the bug/godriver-3616-tad-cursors-to-use-client-timeout branch from 1029688 to 5c404fb Compare September 3, 2025 16:29
@prestonvasquez prestonvasquez enabled auto-merge (squash) September 3, 2025 21:48
@prestonvasquez prestonvasquez merged commit f76320a into mongodb:release/2.3 Sep 4, 2025
34 of 39 checks passed
@prestonvasquez prestonvasquez deleted the bug/godriver-3616-tad-cursors-to-use-client-timeout branch September 4, 2025 18:30
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