Skip to content

Commit

Permalink
[Enhancement] Improve query queue pending timeout error message
Browse files Browse the repository at this point in the history
Signed-off-by: wyb <[email protected]>
  • Loading branch information
wyb committed Dec 13, 2024
1 parent 1300393 commit 0fce494
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fe/fe-core/src/main/java/com/starrocks/qe/QueryQueueManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class QueryQueueManager {
private static final Logger LOG = LogManager.getLogger(QueryQueueManager.class);

private static final String PENDING_TIMEOUT_ERROR_MSG_FORMAT =
"Failed to allocate resource to query: pending timeout [%d], " +
"you could modify the session variable [%s] to pending more time";
"Failed to allocate resource to query: pending timeout [%ds], you could modify %s to pending more time";

private static class SingletonHolder {
private static final QueryQueueManager INSTANCE = new QueryQueueManager();
Expand Down Expand Up @@ -73,9 +72,14 @@ public void maybeWait(ConnectContext context, DefaultCoordinator coord) throws S
if (currentMs >= timeoutMs) {
MetricRepo.COUNTER_QUERY_QUEUE_TIMEOUT.increase(1L);
slotProvider.cancelSlotRequirement(slotRequirement);
int queryQueuePendingTimeout = GlobalVariable.getQueryQueuePendingTimeoutSecond();
int queryTimeout = coord.getJobSpec().getQueryOptions().query_timeout;
String timeoutVar = queryQueuePendingTimeout < queryTimeout ?
String.format("the session variable [%s]", GlobalVariable.QUERY_QUEUE_PENDING_TIMEOUT_SECOND) :
"query/insert timeout";
String errMsg = String.format(PENDING_TIMEOUT_ERROR_MSG_FORMAT,
GlobalVariable.getQueryQueuePendingTimeoutSecond(),
GlobalVariable.QUERY_QUEUE_PENDING_TIMEOUT_SECOND);
Math.min(queryQueuePendingTimeout, queryTimeout),
timeoutVar);
ResourceGroupMetricMgr.increaseTimeoutQueuedQuery(context, 1L);
throw new StarRocksException(errMsg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.starrocks.catalog.ResourceGroupClassifier;
import com.starrocks.catalog.ResourceGroupMgr;
import com.starrocks.common.Config;
import com.starrocks.common.ExceptionChecker;
import com.starrocks.common.Pair;
import com.starrocks.common.StarRocksException;
import com.starrocks.ha.FrontendNodeType;
Expand Down Expand Up @@ -599,6 +600,9 @@ public void testPendingTimeout() throws Exception {
DefaultCoordinator coord = getSchedulerWithQueryId("select count(1) from lineitem");
Assert.assertThrows("pending timeout", StarRocksException.class,
() -> manager.maybeWait(connectContext, coord));
ExceptionChecker.expectThrowsWithMsg(StarRocksException.class,
"the session variable [query_queue_pending_timeout_second]",
() -> manager.maybeWait(connectContext, coord));
}

{
Expand All @@ -608,6 +612,9 @@ public void testPendingTimeout() throws Exception {
getSchedulerWithQueryId("select /*+SET_VAR(query_timeout=2)*/ count(1) from lineitem");
Assert.assertThrows("pending timeout", StarRocksException.class,
() -> manager.maybeWait(connectContext, coord));
ExceptionChecker.expectThrowsWithMsg(StarRocksException.class,
"query/insert timeout",
() -> manager.maybeWait(connectContext, coord));
}

{
Expand Down

0 comments on commit 0fce494

Please sign in to comment.