From d0a3cdfe1a714aa90bf628c487d373705cf89537 Mon Sep 17 00:00:00 2001 From: yiguolei <676222867@qq.com> Date: Wed, 24 May 2023 14:40:33 +0800 Subject: [PATCH] [enhancement](error message) print query id when query timeout (#19972) In regression test, there are many query timeout, but we do not know the query id, and it is too hard to use the sql text to find the query id in audit log. So that I add query id during query timeout. --------- Co-authored-by: yiguolei --- .../src/main/java/org/apache/doris/qe/Coordinator.java | 2 +- .../src/main/java/org/apache/doris/qe/ResultReceiver.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java index 956c40c633..3bb816e857 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java @@ -587,7 +587,7 @@ public class Coordinator { this.timeoutDeadline = System.currentTimeMillis() + queryOptions.getExecutionTimeout() * 1000L; if (topDataSink instanceof ResultSink || topDataSink instanceof ResultFileSink) { TNetworkAddress execBeAddr = topParams.instanceExecParams.get(0).host; - receiver = new ResultReceiver(topParams.instanceExecParams.get(0).instanceId, + receiver = new ResultReceiver(queryId, topParams.instanceExecParams.get(0).instanceId, addressToBackendID.get(execBeAddr), toBrpcHost(execBeAddr), this.timeoutDeadline); if (LOG.isDebugEnabled()) { LOG.debug("dispatch query job: {} to {}", DebugUtil.printId(queryId), diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ResultReceiver.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ResultReceiver.java index ce34099245..9a5e2f673e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/ResultReceiver.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ResultReceiver.java @@ -45,11 +45,13 @@ public class ResultReceiver { private long packetIdx = 0; private long timeoutTs = 0; private TNetworkAddress address; + private Types.PUniqueId queryId; private Types.PUniqueId finstId; private Long backendId; private Thread currentThread; - public ResultReceiver(TUniqueId tid, Long backendId, TNetworkAddress address, long timeoutTs) { + public ResultReceiver(TUniqueId queryId, TUniqueId tid, Long backendId, TNetworkAddress address, long timeoutTs) { + this.queryId = Types.PUniqueId.newBuilder().setHi(queryId.hi).setLo(queryId.lo).build(); this.finstId = Types.PUniqueId.newBuilder().setHi(tid.hi).setLo(tid.lo).build(); this.backendId = backendId; this.address = address; @@ -75,13 +77,13 @@ public class ResultReceiver { while (pResult == null) { long currentTs = System.currentTimeMillis(); if (currentTs >= timeoutTs) { - throw new TimeoutException("query timeout"); + throw new TimeoutException("query timeout, query id = " + DebugUtil.printId(this.queryId)); } try { pResult = future.get(timeoutTs - currentTs, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { // continue to get result - LOG.info("future get interrupted Exception"); + LOG.info("future get interrupted Exception", e); if (isCancel) { status.setStatus(Status.CANCELLED); return null;