Skip to content

Add extra client_ip and timeout columns for show queries#17350

Merged
Wei-hao-Li merged 4 commits intomasterfrom
addShowQ
Mar 25, 2026
Merged

Add extra client_ip and timeout columns for show queries#17350
Wei-hao-Li merged 4 commits intomasterfrom
addShowQ

Conversation

@Wei-hao-Li
Copy link
Collaborator

image

Signed-off-by: Weihao Li <18110526956@163.com>
Signed-off-by: Weihao Li <18110526956@163.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ip and timeout columns to the information_schema.queries table and populate them from active IQueryExecutions.
  • Extend TREE-model SHOW QUERIES output to include ClientIp and Timeout.
  • Update planner/unit/integration tests to reflect the new columns and update IQueryExecution with a getTimeout() 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();

Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
/**
* 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
*/

Copilot uses AI. Check for mistakes.
Comment on lines +284 to +287
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());
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +151 to +154
columnBuilders[3].writeBinary(
BytesUtils.valueOf(queryExecution.getExecuteSQL().orElse("UNKNOWN")));
columnBuilders[4].writeBinary(BytesUtils.valueOf(queryExecution.getClientHostname()));
columnBuilders[5].writeLong(queryExecution.getTimeout());
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +651 to +655
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),
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Signed-off-by: Weihao Li <18110526956@163.com>
@codecov
Copy link

codecov bot commented Mar 24, 2026

Codecov Report

❌ Patch coverage is 58.82353% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.74%. Comparing base (9be854c) to head (9369f90).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
...ional/InformationSchemaContentSupplierFactory.java 0.00% 3 Missing ⚠️
...e/iotdb/db/queryengine/common/MPPQueryContext.java 0.00% 2 Missing ⚠️
.../db/queryengine/plan/execution/QueryExecution.java 0.00% 1 Missing ⚠️
...yengine/plan/execution/config/ConfigExecution.java 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Weihao Li <18110526956@163.com>
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
21.7% Duplication on New Code (required ≤ 5%)

See analysis details on SonarQube Cloud

@Wei-hao-Li Wei-hao-Li merged commit c8455c1 into master Mar 25, 2026
29 of 30 checks passed
@Wei-hao-Li Wei-hao-Li deleted the addShowQ branch March 25, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants