[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 <yiguolei@gmail.com>
This commit is contained in:
yiguolei
2023-05-24 14:40:33 +08:00
committed by GitHub
parent 14b4c7abf9
commit d0a3cdfe1a
2 changed files with 6 additions and 4 deletions

View File

@ -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),

View File

@ -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;