Repository navigation
fix: Register background search tasks as children of parent - #5888
Conversation
Signed-off-by: Simeon Widdis <[email protected]>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (63.86%) is below the target coverage (99.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #5888 +/- ##
============================================
+ Coverage 63.65% 63.86% +0.21%
- Complexity 9021 9097 +76
============================================
Files 959 962 +3
Lines 40823 41057 +234
Branches 4634 4671 +37
============================================
+ Hits 25986 26223 +237
+ Misses 13964 13956 -8
- Partials 873 878 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RyanL1997
left a comment
There was a problem hiding this comment.
LGTM - just left a question to clarify the scope of the original issue.
| restored = true; | ||
| } | ||
| try { | ||
| return QueryProfiling.withCurrentContext(ctx, () -> client.search(request)); |
There was a problem hiding this comment.
This covers an explicit _tasks/_cancel, but I think a query that ends any other way still leaves its in-flight search running:
- On a timeout,
OpenSearchQueryManagerinterrupts the worker thread. - On an early stop such as
head, the enumerator closes andclose()callsnextBatchFuture.cancel(true).CompletableFutureignoresmayInterruptIfRunning, so the prefetch keeps running. - In both cases the PPL task then finishes, and unregistering a parent doesn't cancel its children, so the search runs to completion with nobody waiting for it.
Just wanna leave the question here to see if that is in the scope for #5647?
There was a problem hiding this comment.
Timeouts are handled by a separate mechanism, this PR is orthogonal to that. I think in most timeout cases, the timeout propagates upwards from the underlying search task, not downward from the PPL coordinator thread.
On similar lines, nextBatchFuture's cancellation is orthogonal, and also seems pathological. You need to somehow have a join with individual pages taking multiple seconds for the problem to be measurable, and this just doesn't happen for most joins.
I think on both lines we can merge and file/fix separate bug reports iff they come up.
I also think it's ok if timeouts are looser since from the user perspective that behavior generally looks like "the broken query should be cleaned up eventually," whereas cancellation is more analogous to an emergency stop. Even in the worst case, the diff isn't more than ~15 seconds.
Description
OpenSearch automatically propagates task cancellation to any child tasks, but we weren't actually marking our search tasks as children of the background search process. This led to zombie tasks being left behind on query cancellation.
Related Issues
Resolves #5647
Check List
--signoffor-s.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.