feat(): Adding 'finishingTime' to QueryStatistics#27420
Merged
spershin merged 1 commit intoprestodb:masterfrom Mar 24, 2026
Merged
feat(): Adding 'finishingTime' to QueryStatistics#27420spershin merged 1 commit intoprestodb:masterfrom
spershin merged 1 commit intoprestodb:masterfrom
Conversation
Summary: We noticed that finishing stage can take a sinigificant amount of time to completed and is added to the execution time. For troubleshooting and debugging it would be good to expose the 'finishingTime'. This change is adding 'finishingTime' to QueryStatistics, so it can be used further in events and event listeners. Differential Revision: D97861145
|
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a new finishingTime field to QueryStatistics and threads it through query monitoring and test helpers so query events can expose finishing stage duration. Class diagram for updated QueryStatistics and its use in QueryMonitorclassDiagram
class QueryStatistics {
- Duration planningTime
- Optional~Duration~ analysisTime
- Duration executionTime
- Duration finishingTime
- int peakRunningTasks
- long peakUserMemoryBytes
- long peakTotalNonRevocableMemoryBytes
+ QueryStatistics(Duration planningTime, Optional~Duration~ analysisTime, Duration executionTime, Duration finishingTime, int peakRunningTasks, long peakUserMemoryBytes, long peakTotalNonRevocableMemoryBytes, long totalCpuTimeSecs, long totalScheduledTimeSecs, long totalBlockedTimeSecs, long totalAllocationBytes, long peakTotalMemoryBytes, long peakTaskTotalMemoryBytes, int totalTasks, int runningTasks, int completedTasks, int failedTasks, int totalDrivers, int queuedDrivers, int runningDrivers, int blockedDrivers, int completedDrivers, double cumulativeUserMemory, double cumulativeTotalMemory, double cumulativeCpuTimeSecs, double cumulativeScheduledTimeSecs, double cumulativeBlockedTimeSecs)
+ Duration getPlanningTime()
+ Optional~Duration~ getAnalysisTime()
+ Duration getExecutionTime()
+ Duration getFinishingTime()
+ int getPeakRunningTasks()
+ long getPeakUserMemoryBytes()
+ long getPeakTotalNonRevocableMemoryBytes()
}
class QueryMonitor {
+ void queryImmediateFailureEvent(BasicQueryInfo queryInfo, ExecutionFailureInfo failure)
- QueryStatistics createQueryStatistics(QueryInfo queryInfo)
- QueryStatistics createQueryStatistics(BasicQueryInfo basicQueryInfo)
}
QueryMonitor ..> QueryStatistics : creates_with_finishingTime
QueryInfo --> QueryStatistics : stats_source
BasicQueryInfo --> QueryStatistics : basic_stats_source
QueryInfo ..> QueryMonitor : used_by
BasicQueryInfo ..> QueryMonitor : used_by
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Adding a non-optional
finishingTimeparameter to theQueryStatisticsconstructor in the SPI is a breaking change for any external event listeners constructing this type; consider adding an overloaded constructor (or a builder) that supplies a default value to preserve binary/source compatibility. - For cases where a meaningful finishing phase does not exist (e.g., immediate failure paths), you currently pass
Duration.ofMillis(0); consider whether anOptional<Duration>would better distinguish 'no finishing phase' from 'zero-duration finishing phase', or at least clarify and consistently apply the convention across all call sites.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Adding a non-optional `finishingTime` parameter to the `QueryStatistics` constructor in the SPI is a breaking change for any external event listeners constructing this type; consider adding an overloaded constructor (or a builder) that supplies a default value to preserve binary/source compatibility.
- For cases where a meaningful finishing phase does not exist (e.g., immediate failure paths), you currently pass `Duration.ofMillis(0)`; consider whether an `Optional<Duration>` would better distinguish 'no finishing phase' from 'zero-duration finishing phase', or at least clarify and consistently apply the convention across all call sites.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
arhimondr
approved these changes
Mar 24, 2026
This was referenced Mar 31, 2026
15 tasks
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.
Summary:
We noticed that finishing stage can take a sinigificant amount of time to completed and is added to the execution time.
For troubleshooting and debugging it would be good to expose the 'finishingTime'.
This change is adding 'finishingTime' to QueryStatistics, so it can be used further in events and event listeners.
Differential Revision: D97861145
Release Notes
Please follow release notes guidelines and fill in the release notes below.
Summary by Sourcery
Expose query finishing time in query statistics and propagate it through query monitoring and tests.
New Features:
Tests: