Add coordinator results spooling#27211
Draft
tdcmeehan wants to merge 1 commit intoprestodb:masterfrom
Draft
Conversation
Contributor
Reviewer's GuideAdds an optional coordinator-side result spooling layer that buffers query output to a spooling output buffer on the coordinator, gates delivery to clients until query completion, and wires this into query lifecycle, configuration, metrics, and tests. Class diagram for coordinator result spooling componentsclassDiagram
class Query {
- QueryManager queryManager
- ExchangeClient exchangeClient
- Optional~CoordinatorResultBuffer~ coordinatorResultBuffer
- RetryCircuitBreaker retryCircuitBreaker
- RetryConfig retryConfig
+ static Query create(Session session, String slug, QueryManager queryManager, TransactionManager transactionManager, AccessControl accessControl, SessionPropertyManager sessionPropertyManager, ExchangeClientSupplier exchangeClientSupplier, ExecutorService executor, BoundedExecutor responseExecutor, ScheduledExecutorService timeoutExecutor, BlockEncodingSerde blockEncodingSerde, RetryCircuitBreaker retryCircuitBreaker, RetryConfig retryConfig, Optional~URI~ retryUrl, OptionalLong retryExpirationEpochTime, boolean isRetryQuery, Optional~CoordinatorResultBuffer~ coordinatorResultBuffer)
- Query(Session session, String slug, QueryManager queryManager, TransactionManager transactionManager, AccessControl accessControl, SessionPropertyManager sessionPropertyManager, ExchangeClient exchangeClient, ExecutorService executor, BoundedExecutor responseExecutor, ScheduledExecutorService timeoutExecutor, BlockEncodingSerde blockEncodingSerde, RetryCircuitBreaker retryCircuitBreaker, RetryConfig retryConfig, Optional~CoordinatorResultBuffer~ coordinatorResultBuffer)
+ void cancel()
+ synchronized void dispose()
- ListenableFuture~?~ getFutureStateChange()
- synchronized QueryResults getNextResult(long token, UriInfo uriInfo, String scheme, DataSize targetResultSize, boolean binaryResults)
- SerializedPage pollNextPage()
}
class CoordinatorResultBuffer {
- ExchangeClient exchangeClient
- SpoolingOutputBuffer storageBuffer
- RuntimeStats runtimeStats
- OutputBufferId outputBufferId
- Deque~SerializedPage~ readAheadBuffer
- long readSequenceId
- boolean released
- boolean discarded
- boolean exchangeClientDrained
- boolean storageBufferComplete
- ListenableFuture~BufferResult~ pendingStorageRead
+ CoordinatorResultBuffer(ExchangeClient exchangeClient, SpoolingOutputBuffer storageBuffer, RuntimeStats runtimeStats)
+ synchronized void drainExchangeClient()
+ synchronized SerializedPage pollPage()
- void processStorageReadResult(BufferResult result)
+ synchronized void release()
+ synchronized void discardForRetry()
+ synchronized boolean isFinished()
+ synchronized boolean hasRemainingData()
}
class LocalQueryProvider {
- QueryManager queryManager
- TransactionManager transactionManager
- AccessControl accessControl
- SessionPropertyManager sessionPropertyManager
- ExchangeClientSupplier exchangeClientSupplier
- ExecutorService executor
- BoundedExecutor responseExecutor
- ScheduledExecutorService timeoutExecutor
- RetryCircuitBreaker retryCircuitBreaker
- RetryConfig retryConfig
- SpoolingOutputBufferFactory spoolingOutputBufferFactory
- ConcurrentMap~QueryId, Query~ queries
+ LocalQueryProvider(QueryManager queryManager, TransactionManager transactionManager, AccessControl accessControl, SessionPropertyManager sessionPropertyManager, ExchangeClientSupplier exchangeClientSupplier, ExecutorService executor, BoundedExecutor responseExecutor, ScheduledExecutorService timeoutExecutor, RetryCircuitBreaker retryCircuitBreaker, RetryConfig retryConfig, SpoolingOutputBufferFactory spoolingOutputBufferFactory)
+ Query getQuery(QueryId queryId, String slug, Optional~URI~ retryUrl, OptionalLong retryExpirationEpochTime, boolean isRetryQuery)
}
class FeaturesConfig {
- DataSize spoolingOutputBufferThreshold
- String spoolingOutputBufferTempStorage
- boolean coordinatorOutputBufferingEnabled
+ boolean isCoordinatorOutputBufferingEnabled()
+ FeaturesConfig setCoordinatorOutputBufferingEnabled(boolean coordinatorOutputBufferingEnabled)
}
class SystemSessionProperties {
<<final>>
+ static String COORDINATOR_OUTPUT_BUFFERING_ENABLED
+ static boolean isCoordinatorOutputBufferingEnabled(Session session)
}
class RuntimeStats {
+ void addMetricValue(String name, RuntimeUnit unit, long value)
}
class SpoolingOutputBuffer {
+ void enqueue(Lifespan lifespan, List~SerializedPage~ pages)
+ ListenableFuture~BufferResult~ get(OutputBufferId bufferId, long token, long maxSize)
+ void setNoMorePages()
+ void destroy()
}
class ExchangeClient {
+ SerializedPage pollPage()
+ boolean isClosed()
}
class BufferResult {
+ List~SerializedPage~ getSerializedPages()
+ long getNextToken()
+ boolean isBufferComplete()
}
class SpoolingOutputBufferFactory {
+ SpoolingOutputBuffer createSpoolingOutputBuffer(TaskId taskId, String bufferInstanceId, OutputBuffers outputBuffers, StateMachine~BufferState~ bufferState)
}
Query --> "0..1" CoordinatorResultBuffer : uses
LocalQueryProvider --> Query : creates
LocalQueryProvider --> SpoolingOutputBufferFactory : uses
LocalQueryProvider --> CoordinatorResultBuffer : constructs
CoordinatorResultBuffer --> ExchangeClient : wraps
CoordinatorResultBuffer --> SpoolingOutputBuffer : delegates
CoordinatorResultBuffer --> RuntimeStats : recordsMetrics
CoordinatorResultBuffer --> BufferResult : readsFrom
FeaturesConfig --> SystemSessionProperties : configDefaults
SystemSessionProperties --> FeaturesConfig : readsDefaults
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Description
Motivation and Context
Impact
Test Plan
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
If release note is NOT required, use:
Summary by Sourcery
Introduce coordinator-side result buffering that spools query output to a storage-backed buffer before delivering results to clients and integrates it into the query protocol.
New Features:
Enhancements:
Tests: