Skip to content

PYTHON-6140 [Build Failure] TestBSON.test_encode_size_limit MemoryError on Windows - #3092

Merged
blink1073 merged 3 commits into
mongodb:mainfrom
blink1073:PYTHON-6140
Oct 2, 2026
Merged

blink1073 merged 3 commits into
mongodb:mainfrom
blink1073:PYTHON-6140

Conversation

@blink1073

@blink1073 blink1073 commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

PYTHON-6140

Changes in this PR

Skip TestBSON.test_encode_size_limit on hosts with less than 6GiB of total physical memory. The test needs ~4GiB of peak memory to encode a document that exceeds the BSON size limit, but on 4GB windows-64-vsMulti-small hosts the allocations fail with MemoryError before the expected ValueError is raised.

Test Plan

  • Verified locally: test_encode_size_limit now skips on a 4GiB host.
  • All Win32 tests pass in CI.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)? — Not necessary, test-only change.
  • Is there test coverage? — N/A, this change is test infrastructure.
  • Is any followup work tracked in a JIRA ticket? — Backport to v4.18 required (the failure also occurs on that branch).

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?

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The focused test-only change matches the stated requirements, with no blocking issues identified; Windows CI verification remains pending.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents low-memory hosts from failing the BSON size-limit test with MemoryError instead of the expected ValueError.

Changes:

  • Detect total physical memory on Windows and other supported platforms.
  • Skip the affected test below 6 GiB; retain execution when memory is unknown.
File Description
test/​test_bson.py Adds memory detection and a targeted test skip.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@blink1073
blink1073 marked this pull request as ready for review October 2, 2026 15:44
@blink1073
blink1073 requested a review from a team as a code owner October 2, 2026 15:44
@blink1073
blink1073 requested a review from NoahStapp October 2, 2026 15:44

@NoahStapp NoahStapp left a comment

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.

Honest question: what if we just stopped testing on any platforms that can't handle this test? Do we know how many users could even encounter this?

@blink1073

Copy link
Copy Markdown
Member Author

Honest question: what if we just stopped testing on any platforms that can't handle this test? Do we know how many users could even encounter this?

If we hard-code an OS, it would still fail in a container. We could try to nail down the conditions, but I think it would be more likely that we accidentally stop testing. What if we just unconditionally catch the MemoryError?

@blink1073

Copy link
Copy Markdown
Member Author

I updated to only do the memory probe on linux.

@blink1073
blink1073 requested a review from NoahStapp October 2, 2026 19:09
@blink1073
blink1073 merged commit 43a4f10 into mongodb:main Oct 2, 2026
68 of 69 checks passed
@blink1073
blink1073 deleted the PYTHON-6140 branch October 2, 2026 19:50
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