Add extra client_ip and timeout columns for show queries#17350
Add extra client_ip and timeout columns for show queries#17350Wei-hao-Li merged 4 commits intomasterfrom
Conversation
Wei-hao-Li
commented
Mar 24, 2026
Signed-off-by: Weihao Li <18110526956@163.com>
There was a problem hiding this comment.
Pull request overview
This PR extends SHOW QUERIES / information_schema.queries to expose additional runtime metadata (client IP and timeout) so operators can more easily understand who initiated a query and what its configured execution timeout is.
Changes:
- Add
client_ipandtimeoutcolumns to theinformation_schema.queriestable and populate them from activeIQueryExecutions. - Extend TREE-model
SHOW QUERIESoutput to includeClientIpandTimeout. - Update planner/unit/integration tests to reflect the new columns and update
IQueryExecutionwith agetTimeout()API.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/InformationSchema.java | Adds client_ip and timeout columns to information_schema.queries. |
| iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java | Adds new SHOW QUERIES headers/consts for client IP + timeout; updates header types. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/source/ShowQueriesNode.java | Derives SHOW QUERIES output column names from showQueriesColumnHeaders. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/IQueryExecution.java | Adds getTimeout() to expose per-execution timeout. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/QueryExecution.java | Implements getTimeout() via MPPQueryContext. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java | Implements getTimeout() via MPPQueryContext. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/ShowQueriesOperator.java | Outputs new TREE SHOW QUERIES columns: client IP + timeout. |
| iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/InformationSchemaContentSupplierFactory.java | Populates information_schema.queries rows with client_ip and timeout. |
| iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/plan/relational/planner/informationschema/ShowQueriesTest.java | Updates planner expectations for new queries columns. |
| iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/MergeTreeSortOperatorTest.java | Updates test IQueryExecution fake to implement getTimeout(). |
| integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java | Updates IT assertions for information_schema.queries schema and columns list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -70,6 +70,8 @@ public interface IQueryExecution { | |||
| */ | |||
| long getTotalExecutionTime(); | |||
|
|
|||
There was a problem hiding this comment.
The new getTimeout() method has no contract documented (unit, meaning of 0/negative/Long.MAX_VALUE, whether it’s per-query or session-level, etc.). Since this value is now surfaced via SHOW QUERIES/information_schema, please add Javadoc specifying at least the unit (ms) and semantics so callers don’t misinterpret it.
| /** | |
| * Returns the timeout for this query execution in milliseconds. | |
| * | |
| * <p>The returned value applies to this query execution instance only (per-query timeout). | |
| * | |
| * <p>Semantics of special values: | |
| * <ul> | |
| * <li>{@code timeout > 0}: maximum allowed execution time in milliseconds for this query.</li> | |
| * <li>{@code timeout <= 0}: no timeout is configured for this query (unlimited).</li> | |
| * <li>{@code Long.MAX_VALUE}: effectively treated as no timeout.</li> | |
| * </ul> | |
| * | |
| * @return the configured timeout in milliseconds for this query | |
| */ |
| BytesUtils.valueOf(queryExecution.getExecuteSQL().orElse("UNKNOWN"))); | ||
| columnBuilders[5].writeBinary(BytesUtils.valueOf(queryExecution.getUser())); | ||
| columnBuilders[6].writeBinary(BytesUtils.valueOf(queryExecution.getClientHostname())); | ||
| columnBuilders[7].writeLong(queryExecution.getTimeout()); |
There was a problem hiding this comment.
The new client_ip / ClientIp columns are populated from queryExecution.getClientHostname(). The naming suggests an IP address, but the API returns a “hostname”/cliHostname; if this can be a DNS name (or includes port), the column name is misleading. Either ensure the stored value is a normalized IP address (and ideally rename the accessor accordingly) or consider exposing it as client_host/client_hostname instead.
| columnBuilders[3].writeBinary( | ||
| BytesUtils.valueOf(queryExecution.getExecuteSQL().orElse("UNKNOWN"))); | ||
| columnBuilders[4].writeBinary(BytesUtils.valueOf(queryExecution.getClientHostname())); | ||
| columnBuilders[5].writeLong(queryExecution.getTimeout()); |
There was a problem hiding this comment.
This populates the new ClientIp column using getClientHostname(). If the value isn’t guaranteed to be an IP address (e.g., could be a hostname), consider normalizing it to an IP (or renaming the column/accessor) to avoid misleading output from SHOW QUERIES.
| new ColumnHeader(QUERY_ID, TSDataType.STRING), | ||
| new ColumnHeader(DATA_NODE_ID, TSDataType.INT32), | ||
| new ColumnHeader(ELAPSED_TIME, TSDataType.FLOAT), | ||
| new ColumnHeader(STATEMENT, TSDataType.TEXT)); | ||
| new ColumnHeader(STATEMENT, TSDataType.STRING), | ||
| new ColumnHeader(CLIENT_IP_TREE_MODEL, TSDataType.STRING), |
There was a problem hiding this comment.
showQueriesColumnHeaders switches string columns (e.g., QueryId/Statement/ClientIp) from TSDataType.TEXT to TSDataType.STRING. This changes the result schema of the TREE-model SHOW QUERIES statement and can break compatibility with older clients/components that only expect TEXT in show-statement outputs. Consider keeping existing columns as TEXT and only adding the new columns, also as TEXT, unless there is a hard requirement to return STRING here.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #17350 +/- ##
============================================
+ Coverage 39.72% 39.74% +0.01%
Complexity 312 312
============================================
Files 5126 5127 +1
Lines 346242 346292 +50
Branches 44085 44094 +9
============================================
+ Hits 137551 137636 +85
+ Misses 208691 208656 -35 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Weihao Li <18110526956@163.com>
|

