Skip to content

Fixed concurrency issue in MetaDb chunk expansion#9508

Merged
michaelstaib merged 2 commits intomainfrom
mst/metadb-expansion
Apr 7, 2026
Merged

Fixed concurrency issue in MetaDb chunk expansion#9508
michaelstaib merged 2 commits intomainfrom
mst/metadb-expansion

Conversation

@michaelstaib
Copy link
Copy Markdown
Member

@michaelstaib michaelstaib commented Apr 7, 2026

Fixes #9500

Copilot AI review requested due to automatic review settings April 7, 2026 19:14
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

Addresses a concurrency hazard in ResultDocument.MetaDb chunk-array expansion by preventing pooled chunk buffers from being returned while they may still be observed by concurrent readers, and adds an integration regression test intended to cover the large paging + DataLoader scenario.

Changes:

  • Retain the previous _chunks buffer across expansions and only return it to the pool on the next expansion or Dispose.
  • Introduce a volatile cursor value (_nextValue) to provide an atomic/read-friendly cursor snapshot for readers.
  • Add a new integration test that pages 100,000 nodes and resolves a composite DataLoader field with a wide selection set.

Reviewed changes

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

File Description
src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/Issue9500Tests.cs Adds a large paging + DataLoader integration test aimed at reproducing the reported failure mode.
src/HotChocolate/Core/src/Types/Text/Json/ResultDocument.MetaDb.cs Prevents premature ArrayPool returns during chunk-array expansion; adds an atomic cursor snapshot for concurrent readers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelstaib michaelstaib merged commit d68df74 into main Apr 7, 2026
130 checks passed
@michaelstaib michaelstaib deleted the mst/metadb-expansion branch April 7, 2026 19:43
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (6a3b7a3) to head (cfdf02e).
⚠️ Report is 1080 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #9508       +/-   ##
==========================================
- Coverage   74.16%       0   -74.17%     
==========================================
  Files        2677       0     -2677     
  Lines      140790       0   -140790     
  Branches    16371       0    -16371     
==========================================
- Hits       104421       0   -104421     
+ Misses      30774       0    -30774     
+ Partials     5595       0     -5595     
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ResultDocument.GetSelection throws "Specified argument was out of the range" with large result sets containing composite objects

2 participants