[Analytics Engine] Fix Arrow import staging allocator lifetime (transport race and leaked child allocators) - #22800
Conversation
…ng one per batch Signed-off-by: Lantao Jin <ltjin@amazon.com>
PR Reviewer Guide 🔍(Review updated until commit f278551)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to f278551 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 5ef81a4
Suggestions up to commit 1deaf21
Suggestions up to commit 6aa42f5
Suggestions up to commit 70f32a2
Suggestions up to commit 83ec94b
|
Signed-off-by: Lantao Jin <ltjin@amazon.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #22800 +/- ##
============================================
- Coverage 71.66% 71.58% -0.08%
+ Complexity 77365 77330 -35
============================================
Files 6170 6170
Lines 359698 359710 +12
Branches 52458 52460 +2
============================================
- Hits 257782 257510 -272
- Misses 81509 81753 +244
- Partials 20407 20447 +40 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Persistent review updated to latest commit 6aa42f5 |
|
❌ Gradle check result for 6aa42f5: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
…ream Signed-off-by: Lantao Jin <ltjin@amazon.com>
|
Persistent review updated to latest commit 1deaf21 |
…mport-staging-leak
|
Persistent review updated to latest commit 5ef81a4 |
|
❌ Gradle check result for 5ef81a4: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
Persistent review updated to latest commit f278551 |
|
thanks @LantaoJin this lgtm, once apache/arrow-java#1240 is deployed in the next arrow-java version we can likely revert to a per-query allocator, and avoid leaks on import ooms. |
…port race and leaked child allocators) (opensearch-project#22800) * Use one stream-scoped Arrow import staging allocator instead of closing one per batch Signed-off-by: Lantao Jin <ltjin@amazon.com> * address comment Signed-off-by: Lantao Jin <ltjin@amazon.com> * Make the Arrow import staging allocator node-scoped instead of per-stream Signed-off-by: Lantao Jin <ltjin@amazon.com> --------- Signed-off-by: Lantao Jin <ltjin@amazon.com>
Description
Arrow C Data batches are imported onto a dedicated staging allocator (unbounded, parented at the root) because arrow-java ≤ 18.1.0 doesn't roll back a mid-import failure — the C Data release callback never fires and the whole native batch leaks in the producer's native allocator. That allocator was created and closed per stream, which can't work.
FlightServerChannelbuilds its reused stream root on the first batch's allocator ("The producer's allocator must be long-lived (not closed per-request)") and frees it asynchronously, so closing at stream close raced the transport and threwIllegalStateException: Memory was leaked by query:Fix: one node-scoped
arrow-import-stagingallocator, created and closed byAnalyticsSearchService. Streams borrow it and never create or close an allocator, so there's no race and nothing accumulates. It reaches all import paths — shard scan (ShardScanExecutionContext), QTF fetch (fetchByRowIds), and coordinator reduce (ExchangeSinkContext). This also fixes a pre-existing instance of the same leak inAbstractDatafusionReduceSink#drainOutputIntoDownstream, which minted a staging child per drain and never closed it.Related Issues
Resolves #22799
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.