Skip to content

PYTHON-5668 - Merge backpressure branch into mainline#2729

Merged
NoahStapp merged 340 commits intomasterfrom
backpressure
Apr 14, 2026
Merged

PYTHON-5668 - Merge backpressure branch into mainline#2729
NoahStapp merged 340 commits intomasterfrom
backpressure

Conversation

@NoahStapp
Copy link
Copy Markdown
Contributor

@NoahStapp NoahStapp commented Mar 12, 2026

PYTHON-5668

Changes in this PR

Merge backpressure branch into master.

Reviewers can ignore all spec test changes. Focus on the actual code changes within pymongo/ and the prose tests.

Test Plan

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 54 out of 55 changed files in this pull request and generated 5 comments.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 54 out of 55 changed files in this pull request and generated 6 comments.

and "errorLabels" in error.details
and isinstance(error.details["errorLabels"], list)
and "RetryableError" in error.details["errorLabels"]
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could this ^ be error.has_error_label("RetryableError") with an isinstance(error, PyMongoError) guard?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can you expand on what this if statement would look like with that change?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  retryable_label_error = (                                                                                                                                        
      isinstance(error, PyMongoError)
      and error.has_error_label("RetryableError")                                                                                                                  
  )       

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, that is a clarity and consistency improvement.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 52 out of 53 changed files in this pull request and generated 3 comments.

isinstance(exc, OperationFailure)
and exc_code not in helpers_shared._RETRYABLE_ERROR_CODES
)
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggest minor improvement to conditional clarity via additional parenthesis wrapping the outer or condition:


  if (                                                                                                                                
      not self._client.options.retry_reads                                                                                          
      or (                                                                                                                            
          not always_retryable
          and (                                                                                                                       
              self._is_not_eligible_for_retry()                                                                                     
              or (
                  isinstance(exc, OperationFailure)
                  and exc_code not in helpers_shared._RETRYABLE_ERROR_CODES
              )                                                                                                                       
          )
      )                                                                                                                               
  ):             


self._always_retryable = always_retryable
if overloaded:
delay = self._retry_policy.backoff(self._attempt_number) if overloaded else 0
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Already inside if overloaded

aclark4life
aclark4life previously approved these changes Apr 13, 2026
Copy link
Copy Markdown
Contributor

@aclark4life aclark4life left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

Copy link
Copy Markdown
Contributor

@sleepyStick sleepyStick left a comment

Choose a reason for hiding this comment

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

phew big PR -- sorry it took me a hot minute to review it, i've been looking at bits of it throughout the day (between workloads lol ;-;) just one change but otherwise its good! Great work!

change-streams|change_streams)
cpjson change-streams/tests/ change_streams/
;;
client-backpressure|client_backpressure)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think PYTHON-5668.patch can be removed too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch! At long last

Copy link
Copy Markdown
Contributor

@sleepyStick sleepyStick left a comment

Choose a reason for hiding this comment

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

woo!!! one step closer to being done with backpressure!

@NoahStapp NoahStapp merged commit e1751ff into master Apr 14, 2026
87 of 118 checks passed
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.

7 participants