[pinot-server/ proactive-query-killing] (1/2) add initial SPI implementation for supporting query killing based on Scan Cost#18102
Open
anuragrai16 wants to merge 5 commits intoapache:masterfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #18102 +/- ##
============================================
+ Coverage 63.85% 63.93% +0.07%
- Complexity 1573 1594 +21
============================================
Files 3167 3184 +17
Lines 192092 193690 +1598
Branches 29601 29912 +311
============================================
+ Hits 122666 123835 +1169
- Misses 59774 60072 +298
- Partials 9652 9783 +131
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation for #18043
This PR introduces all core classes for a proactive, scan-cost-based query killing framework. No existing query execution path is modified in this PR. A follow-up PR will wire these into BaseOperator.checkTermination() and the operator instrumentation points.
New classes:
QueryScanCostContext(pinot-spi) — LongAdder-based, thread-safe accumulator for numEntriesScannedInFilter, numDocsScanned, andnumEntriesScannedPostFilter. One instance per query, shared across segment worker threads.
QueryKillingStrategy(pinot-core) — Interface for pluggable kill decisions. Includes shouldTerminate(), buildKillReport(),getErrorCode(), and forQuery() for table-level threshold overrides.
ScanEntriesThresholdStrategy(pinot-core) — Default strategy. Kills queries exceeding maxEntriesScannedInFilter or maxDocsScanned.Threshold of Long.MAX_VALUE disables that metric. Includes a nested Factory that validates config at init and logs a warning if no
thresholds are set.
CompositeQueryKillingStrategy(pinot-core) — Combines strategies with AND/OR semantics.QueryKillingStrategyFactory(pinot-core) — Factory interface for config-driven strategy loading. Custom strategies are plugged in bysetting accounting.scan.based.killing.strategy.factory.class.name to a factory class
QueryKillReport(pinot-core) — Immutable snapshot of a kill event. Captures all metrics at creation timeProduces customer-facing error messages with actionable advice and structured internal log messages.
QueryKillingManager(pinot-core) — Singleton manager. Builds strategy once at init via factory, delegatesshouldTerminate()/buildKillReport() to the strategy.
Table-Level overrides supported
Table-level overrides via QueryConfig. Table config takes precedence over cluster config; null means use cluster default.
Error code: QUERY_SCAN_LIMIT_EXCEEDED (246, HTTP 400) - distinguishes scan kills (client problem) from OOM kills (server problem, 503).
Minimum config to enable