Skip to content

Commit

Permalink
change default setting of monitor queries
Browse files Browse the repository at this point in the history
Signed-off-by: Murphy <[email protected]>
  • Loading branch information
murphyatwork committed Dec 9, 2024
1 parent ad5973a commit e338597
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
28 changes: 15 additions & 13 deletions fe/fe-core/src/main/java/com/starrocks/qe/QeProcessorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,26 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import static com.starrocks.mysql.MysqlCommand.COM_STMT_EXECUTE;

public final class QeProcessorImpl implements QeProcessor, MemoryTrackable {
private static final Logger LOG = LogManager.getLogger(QeProcessorImpl.class);
private static final int MEMORY_QUERY_SAMPLES = 10;
private static final long ONE_MINUTE = 60 * 1000L;
private final Map<TUniqueId, QueryInfo> coordinatorMap = Maps.newConcurrentMap();
private final Map<TUniqueId, Long> monitorQueryMap = Maps.newConcurrentMap();
private final AtomicLong lastCheckTime = new AtomicLong();

public static final QeProcessor INSTANCE;
public static final QeProcessorImpl INSTANCE;
private static final ScheduledExecutorService MONITOR_EXECUTOR;

static {
INSTANCE = new QeProcessorImpl();
MONITOR_EXECUTOR = Executors.newSingleThreadScheduledExecutor();
MONITOR_EXECUTOR.scheduleAtFixedRate(INSTANCE::scanMonitorQueries, 0, 1, TimeUnit.SECONDS);
}

private QeProcessorImpl() {
Expand Down Expand Up @@ -115,19 +118,18 @@ public void registerQuery(TUniqueId queryId, QueryInfo info) throws StarRocksExc
if (result != null) {
throw new StarRocksException("queryId " + queryId + " already exists");
}
scanMonitorQueries();
}

/**
* Scan all monitored queries, cleanup them if expired
*/
private void scanMonitorQueries() {
long now = System.currentTimeMillis();
long lastCheckTime = this.lastCheckTime.get();
if (now - lastCheckTime > ONE_MINUTE && this.lastCheckTime.compareAndSet(lastCheckTime, now)) {
for (Map.Entry<TUniqueId, Long> entry : monitorQueryMap.entrySet()) {
if (now > entry.getValue()) {
LOG.warn("monitor expired, query id = {}", DebugUtil.printId(entry.getKey()));
unregisterQuery(entry.getKey());
monitorQueryMap.remove(entry.getKey());
}
for (Map.Entry<TUniqueId, Long> entry : monitorQueryMap.entrySet()) {
if (now > entry.getValue()) {
LOG.warn("monitor expired, query id = {}", DebugUtil.printId(entry.getKey()));
unregisterQuery(entry.getKey());
monitorQueryMap.remove(entry.getKey());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ public static MaterializedViewRewriteMode parse(String str) {
private int maxPipelineDop = 64;

@VariableMgr.VarAttr(name = PROFILE_TIMEOUT, flag = VariableMgr.INVISIBLE)
private int profileTimeout = 2;
private int profileTimeout = 10;

@VariableMgr.VarAttr(name = RUNTIME_PROFILE_REPORT_INTERVAL)
private int runtimeProfileReportInterval = 10;
Expand Down

0 comments on commit e338597

Please sign in to comment.