Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix](query) Fix the calc logic of dispatch read time #15061

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,34 +126,38 @@ public Future<FragInstanceDispatchResult> dispatch(List<FragmentInstance> instan
// topological dispatch according to dependency relations between FragmentInstances
private Future<FragInstanceDispatchResult> dispatchRead(List<FragmentInstance> instances) {
long startTime = System.nanoTime();
for (FragmentInstance instance : instances) {
try (SetThreadName threadName = new SetThreadName(instance.getId().getFullId())) {
dispatchOneInstance(instance);
} catch (FragmentInstanceDispatchException e) {
return immediateFuture(new FragInstanceDispatchResult(e.getFailureStatus()));
} catch (Throwable t) {
LOGGER.warn(DISPATCH_FAILED, t);
return immediateFuture(
new FragInstanceDispatchResult(
RpcUtils.getStatus(
TSStatusCode.INTERNAL_SERVER_ERROR, UNEXPECTED_ERRORS + t.getMessage())));
} finally {
// friendly for gc, clear the plan node tree, for some queries select all devices, it will
// release lots of memory
if (!queryContext.isExplainAnalyze()) {
// EXPLAIN ANALYZE will use these instances, so we can't clear them
instance.getFragment().clearUselessField();
} else {
// TypeProvider is not used in EXPLAIN ANALYZE, so we can clear it
instance.getFragment().clearTypeProvider();
}

long dispatchReadTime = System.nanoTime() - startTime;
QUERY_EXECUTION_METRIC_SET.recordExecutionCost(DISPATCH_READ, dispatchReadTime);
queryContext.recordDispatchCost(dispatchReadTime);
try {
for (FragmentInstance instance : instances) {
try (SetThreadName threadName = new SetThreadName(instance.getId().getFullId())) {
dispatchOneInstance(instance);
} catch (FragmentInstanceDispatchException e) {
return immediateFuture(new FragInstanceDispatchResult(e.getFailureStatus()));
} catch (Throwable t) {
LOGGER.warn(DISPATCH_FAILED, t);
return immediateFuture(
new FragInstanceDispatchResult(
RpcUtils.getStatus(
TSStatusCode.INTERNAL_SERVER_ERROR, UNEXPECTED_ERRORS + t.getMessage())));
} finally {
// friendly for gc, clear the plan node tree, for some queries select all devices, it will
// release lots of memory
if (!queryContext.isExplainAnalyze()) {
// EXPLAIN ANALYZE will use these instances, so we can't clear them
instance.getFragment().clearUselessField();
} else {
// TypeProvider is not used in EXPLAIN ANALYZE, so we can clear it
instance.getFragment().clearTypeProvider();
}
}
}

return immediateFuture(new FragInstanceDispatchResult(true));
} finally {
long queryDispatchReadTime = System.nanoTime() - startTime;
QUERY_EXECUTION_METRIC_SET.recordExecutionCost(DISPATCH_READ, queryDispatchReadTime);
queryContext.recordDispatchCost(queryDispatchReadTime);
}
return immediateFuture(new FragInstanceDispatchResult(true));
}

private Future<FragInstanceDispatchResult> dispatchWriteSync(List<FragmentInstance> instances) {
Expand Down