Skip to content

PYTHON-5492 Fix handling of MaxTimeMSExpired responses #2477

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 3 commits into from
Aug 16, 2025

Conversation

blink1073
Copy link
Member

@blink1073 blink1073 commented Aug 15, 2025

It turns out we did have a race condition as to whether we'd get a client side or server side timeout. This ensures we get the same information either way.

Also fixes a sporadic bug when installing just by ensuring that the bin dir exists before attempting to install into it.

@blink1073 blink1073 requested a review from sleepyStick August 15, 2025 20:24
@blink1073 blink1073 requested a review from a team as a code owner August 15, 2025 20:24
@blink1073
Copy link
Member Author

drivers-pr-bot please backport to v4.14

@blink1073 blink1073 marked this pull request as draft August 15, 2025 21:35
@blink1073
Copy link
Member Author

Putting back into draft. Even with the flaky, the tests are still failing. We might need to skip and file a SERVER ticket.

@blink1073 blink1073 changed the title PYTHON-5492 Mark csot test as flaky on linux as well PYTHON-5492 Fix handling of MaxTimeMSExpired responses Aug 15, 2025
@blink1073 blink1073 marked this pull request as ready for review August 15, 2025 22:50
@blink1073 blink1073 merged commit 9dbccbe into mongodb:master Aug 16, 2025
76 of 79 checks passed
@blink1073 blink1073 deleted the PYTHON-5492-2 branch August 16, 2025 00:13
mongodb-dbx-release-bot bot pushed a commit that referenced this pull request Aug 16, 2025
blink1073 added a commit that referenced this pull request Aug 18, 2025
# Append timeout details to MaxTimeMSExpired responses.
if first.get("code") == 50:
timeout_details = _get_timeout_details(conn.opts) # type:ignore[has-type]
first["errmsg"] += format_timeout_details(timeout_details) # type:ignore[index]
Copy link
Member

@ShaneHarvey ShaneHarvey Aug 18, 2025

Choose a reason for hiding this comment

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

This will fail if the document_class is RawBSONDocument:

>>> from bson.raw_bson import *
>>> c = MongoClient(document_class=RawBSONDocument)
>>> _ = c.t.t.insert_many([{'x':i} for i in range(1000000)])
>>> c.t.t.find_one({'x': -1}, maxTimeMS=1)
...
  File "/Users/shane/git/mongo-python-driver/pymongo/synchronous/server.py", line 231, in run_operation
    first["errmsg"] += format_timeout_details(timeout_details)  # type:ignore[index]
    ~~~~~^^^^^^^^^^
TypeError: 'RawBSONDocument' object does not support item assignment

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.

3 participants