Skip to content

enh(grant): timeseries calculation excluding system tables#34778

Open
kailixu wants to merge 5 commits into3.3.8from
enh/TS-6672169603-3.3.8
Open

enh(grant): timeseries calculation excluding system tables#34778
kailixu wants to merge 5 commits into3.3.8from
enh/TS-6672169603-3.3.8

Conversation

@kailixu
Copy link
Contributor

@kailixu kailixu commented Mar 13, 2026

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the timeseries calculation within the grant system by explicitly excluding a broader set of internal system tables. This change aims to improve the precision of resource usage metrics by focusing on user-defined data. Accompanying this enhancement is the addition of a robust test suite that thoroughly verifies the new exclusion logic and the overall accuracy of timeseries statistics under various DDL operations.

Highlights

  • Timeseries Calculation Enhancement: Expanded the list of internal system tables that are excluded from timeseries calculations, ensuring more accurate resource reporting.
  • Comprehensive Test Coverage: Introduced a new, extensive Python test suite to validate the accuracy of timeseries statistics, including the specific exclusion logic for system tables in 'audit' and 'log' databases.
  • CI Integration: Integrated the newly added grant-related test cases into the continuous integration pipeline to ensure ongoing validation of the timeseries calculation logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • source/dnode/vnode/src/vnd/vnodeQuery.c
    • Updated the tkLogStb array with numerous additional system table names to be excluded from timeseries calculations.
  • test/cases/32-Grants/test_grant_basic.py
    • Added a new Python test file, test_grant_basic.py, which includes comprehensive test cases for verifying timeseries statistics, system table exclusion in 'audit' and 'log' databases, and the impact of DDL operations.
    • Implemented a utility function parseSystemStbArrayFromC to dynamically read system table lists from C source files for testing purposes.
  • test/ci/cases.task
    • Added an entry to include test_grant_basic.py in the CI test execution for the '32-Grants' category.
Activity
  • The pull request was opened by kailixu.
  • The description includes a standard checklist for user manual updates, test case automation, and test coverage, which are currently unchecked.
  • No specific human activity beyond the initial commit is recorded in the provided context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the timeseries calculation for grants by excluding a list of system tables. The change in vnodeQuery.c adds a significant number of tables to the exclusion list. A new, comprehensive test suite is added in test_grant_basic.py to verify this new logic and other grant-related timeseries calculations.

My review found a few areas for improvement:

  • In the C code, the new list of tables should be sorted for better maintainability.
  • The new Python test file is missing an import for the subprocess module, which will cause it to fail.
  • The test file also uses shell=True in subprocess calls where it's not necessary, and contains a hardcoded path that could be made more robust.

I've provided suggestions to address these points.

Comment on lines +1220 to +1262
"taosd_dnodes_status",
"adapter_conn_pool",
"taosd_vnodes_info",
"taosd_dnodes_metrics",
"taosd_vgroups_info",
"taos_sql_req",
"taosd_mnodes_info",
"adapter_c_interface",
"taosd_cluster_info",
"taosd_sql_req",
"taosd_dnodes_info",
"adapter_requests",
"taosd_write_metrics",
"adapter_status",
"taos_slow_sql",
"taos_slow_sql_detail",
"taosd_cluster_basic",
"taosd_dnodes_data_dirs",
"taosd_dnodes_log_dirs",
"xnode_agent_activities",
"xnode_task_activities",
"xnode_task_metrics",
"taosx_task_csv",
"taosx_task_progress",
"taosx_task_kinghist",
"taosx_task_tdengine2",
"taosx_task_tdengine3",
"taosx_task_opc_da",
"taosx_task_opc_ua",
"taosx_task_kafka",
"taosx_task_influxdb",
"taosx_task_mqtt",
"taosx_task_avevahistorian",
"taosx_task_opentsdb",
"taosx_task_mysql",
"taosx_task_postgres",
"taosx_task_oracle",
"taosx_task_mssql",
"taosx_task_mongodb",
"taosx_task_sparkplugb",
"taosx_task_orc",
"taosx_task_pulsar",
"taosx_task_pspace"};
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, it's good practice to keep this list of table names sorted alphabetically. This makes it easier to check for existing entries and avoid duplicates in the future.

                          "adapter_c_interface",
                          "adapter_conn_pool",
                          "adapter_requests",
                          "adapter_status",
                          "taos_slow_sql",
                          "taos_slow_sql_detail",
                          "taos_sql_req",
                          "taosd_cluster_basic",
                          "taosd_cluster_info",
                          "taosd_dnodes_data_dirs",
                          "taosd_dnodes_info",
                          "taosd_dnodes_log_dirs",
                          "taosd_dnodes_metrics",
                          "taosd_dnodes_status",
                          "taosd_mnodes_info",
                          "taosd_sql_req",
                          "taosd_vgroups_info",
                          "taosd_vnodes_info",
                          "taosd_write_metrics",
                          "taosx_task_avevahistorian",
                          "taosx_task_csv",
                          "taosx_task_influxdb",
                          "taosx_task_kafka",
                          "taosx_task_kinghist",
                          "taosx_task_mongodb",
                          "taosx_task_mqtt",
                          "taosx_task_mssql",
                          "taosx_task_mysql",
                          "taosx_task_opc_da",
                          "taosx_task_opc_ua",
                          "taosx_task_opentsdb",
                          "taosx_task_orc",
                          "taosx_task_oracle",
                          "taosx_task_postgres",
                          "taosx_task_progress",
                          "taosx_task_pspace",
                          "taosx_task_pulsar",
                          "taosx_task_sparkplugb",
                          "taosx_task_tdengine2",
                          "taosx_task_tdengine3",
                          "xnode_agent_activities",
                          "xnode_task_activities",
                          "xnode_task_metrics"};

def s3_check_show_grants_granted(self):
tdLog.printNoPrefix("======== test show grants granted: ")
try:
process = subprocess.Popen(f'{self.workPath}{os.sep}grantTest 1', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using shell=True with subprocess.Popen can be a security risk if the command string is crafted from external input. While the risk is low here, it's a best practice to avoid it when not strictly necessary. You can pass the command and its arguments as a list to Popen instead.

Suggested change
process = subprocess.Popen(f'{self.workPath}{os.sep}grantTest 1', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process = subprocess.Popen([f'{self.workPath}{os.sep}grantTest', '1'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

tdSql.checkRows(3)

self.genClusterInfo(check=False)
process = subprocess.Popen(f'{self.workPath}{os.sep}grantTest 2', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Similar to the previous comment, it's better to avoid shell=True. The command can be passed as a list of arguments.

Suggested change
process = subprocess.Popen(f'{self.workPath}{os.sep}grantTest 2', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process = subprocess.Popen([f'{self.workPath}{os.sep}grantTest', '2'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)

- Or the database is created with 'is_audit 1' option
"""
# Dynamically parse system supertable arrays from vnodeQuery.c
vnodeQueryPath = os.path.join(self.TDinternal, "community", "source", "dnode", "vnode", "src", "vnd", "vnodeQuery.c")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This hardcoded path to vnodeQuery.c is brittle and might break if the source code directory structure changes. Consider making this more robust. For example, you could determine the repository root programmatically and construct the path from there, or pass the path as a configuration parameter to the test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant