Fix missing expired query callbacks and improve secondary workload queue thread wakeup - #19167
Fix missing expired query callbacks and improve secondary workload queue thread wakeup#19167adasari wants to merge 2 commits into
Conversation
…eue thread wakeup
|
@yashmayya Could you review when you get a chance ? Please feel free to re-assign. |
There was a problem hiding this comment.
Pull request overview
This PR improves the secondary-query scheduling path in pinot-core by (1) reducing idle wakeups in the secondary workload dispatch loop and (2) ensuring expired secondary queries are completed via a callback so their response futures don’t leak.
Changes:
- Update
SecondaryWorkloadQueue.take()to do an untimed wait when empty, and to return expired queries fromtrimExpired()for callback-based completion outside the queue lock. - Extend
SchedulerGroup.trimExpired()to return the removed queries, enabling callers to complete their futures. - Wire expiry handling + worker-release signaling into
BinaryWorkloadScheduler, and add unit tests validating ordering, expiry completion, and wakeup behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pinot-core/src/test/java/org/apache/pinot/core/query/scheduler/SecondaryWorkloadQueueTest.java | New unit tests covering expiry completion, lock behavior, and wakeup signaling semantics. |
| pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/SecondaryWorkloadQueue.java | Adds expiry callback handling, eliminates idle timed polling when the queue is empty, and adds signalWorkersReleased(). |
| pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/SchedulerGroup.java | Changes trimExpired() to return removed queries for completion by callers. |
| pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/BinaryWorkloadScheduler.java | Passes expiry handler into SecondaryWorkloadQueue and signals when workers are released. |
| pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/AbstractSchedulerGroup.java | Implements trimExpired() returning the removed expired queries. |
| executorService.releaseWorkers(); | ||
| schedulerGroup.endQuery(); | ||
| _secondaryQueryQ.signalWorkersReleased(); | ||
| _secondaryRunnerSemaphore.release(); | ||
| checkStopResourceManager(); |
There was a problem hiding this comment.
Added query completion callback functionality when take return null i.e no query.
| /// Signals the reader that reserved threads were released, so canSchedule() may now pass. | ||
| public void signalWorkersReleased() { | ||
| _queueLock.lock(); | ||
| try { | ||
| _queryReaderCondition.signal(); | ||
| } finally { | ||
| _queueLock.unlock(); | ||
| } | ||
| } |
There was a problem hiding this comment.
not worth changing? if the queue is empty, a waiting thread wakes, reacquires the lock, sees the queue is empty, and waits again.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #19167 +/- ##
============================================
+ Coverage 66.57% 66.60% +0.03%
Complexity 1423 1423
============================================
Files 3441 3441
Lines 218320 218365 +45
Branches 34737 34745 +8
============================================
+ Hits 145341 145437 +96
+ Misses 61251 61205 -46
+ Partials 11728 11723 -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:
|
Problems:
BinaryWorkloadSchedulerdispatch thread polls SecondaryWorkloadQueue every 1 ms (default) regardless of whether any secondary queries exist. Secondary queries are not frequent, So on a server with no secondary queries, there are ~1000 needless wakeups per min, per server, on a Thread.MAX_PRIORITY daemon thread.Changes
BinaryWorkloadScheduleronly to begin with,PriorityScheduleris untouched)SecondaryWorkloadQueueonly to begin with,MultiLevelPriorityQueueis untouched)Testing:
Unit tests
SecondaryWorkloadQueueTest