Skip to content

fix: check dnodes status until ready#33366

Merged
feici02 merged 1 commit into3.0from
fix/huoh/TD-38281-3.0
Oct 24, 2025
Merged

fix: check dnodes status until ready#33366
feici02 merged 1 commit into3.0from
fix/huoh/TD-38281-3.0

Conversation

@SallyHuo-TAOS
Copy link
Copy Markdown
Contributor

Description

Please briefly describe the code changes in this pull request.

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?

@SallyHuo-TAOS SallyHuo-TAOS requested a review from a team as a code owner October 24, 2025 08:39
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @SallyHuo-TAOS, 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 enhances the test setup process by introducing a robust waiting mechanism for dnodes. Previously, tests might proceed immediately after dnode creation, potentially leading to failures if the dnodes were not yet fully initialized. The updated logic now actively polls the dnode status, ensuring all required dnodes are in a 'ready' state within a defined timeout period, thereby improving the reliability and consistency of test environments.

Highlights

  • Dnode Readiness Check: Introduced a new mechanism to explicitly check the status of created dnodes, ensuring they are all in a 'ready' state before proceeding with test execution.
  • Timeout for Dnode Readiness: Implemented a 10-second timeout for the dnode readiness check, preventing indefinite waits and providing clear error messages if dnodes fail to become ready.
  • Improved Test Stability: The changes aim to enhance the stability of test setups by addressing potential race conditions where tests might start before all dnodes are fully operational.
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
Copy Markdown
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

The pull request introduces a mechanism to check the status of dnodes until they are ready, adding a timeout to prevent indefinite waiting. The changes involve adding a loop that queries the information_schema.ins_dnodes table, checks the status of each dnode, and exits the loop when all dnodes are ready or the timeout is reached. The review focuses on the correctness and efficiency of the introduced logic.

tdLog.debug(tdSql.query(f"show dnodes", row_tag=True))
count += 1
else:
tdLog.exit(f"{request.session.create_dnode_num} dnodes not all ready within {timeout}s!")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Using tdLog.exit will terminate the test execution, which might not be the desired behavior. A more graceful approach would be to raise an exception, allowing pytest to handle the test failure and report it appropriately.

Consider raising a RuntimeError instead of exiting directly.

Suggested change
tdLog.exit(f"{request.session.create_dnode_num} dnodes not all ready within {timeout}s!")
raise RuntimeError(f"{request.session.create_dnode_num} dnodes not all ready within {timeout}s!")

# 处理 -C 参数,如果未设置 -C 参数,create_dnode_num 和 -N 参数相同
for i in range(1, request.session.create_dnode_num):
tdSql.execute(f"create dnode localhost port {6030+i*100}")
time.sleep(request.session.create_dnode_num)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The sleep duration here is dependent on the number of dnodes being created. This could potentially lead to issues if the dnodes take longer than expected to start. It's better to wait for a fixed small duration here, and rely on the readiness check logic that follows.

Consider reducing this to a fixed small duration, such as 1 second.

Suggested change
time.sleep(request.session.create_dnode_num)
time.sleep(1)

Comment on lines +246 to +248
for i in range(len(tdSql.queryResult)):
if tdSql.queryResult[i][4] == "ready":
status += 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Instead of iterating through the query result and manually incrementing the status counter, you can use a more concise and efficient approach using a generator expression and the sum function. This improves readability and reduces the amount of code.

Consider using a generator expression with sum to count the number of 'ready' dnodes.

        status = sum(1 for row in tdSql.queryResult if row[4] == "ready") # Count 'ready' dnodes

Copy link
Copy Markdown
Member

@feici02 feici02 left a comment

Choose a reason for hiding this comment

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

LGTM

@feici02 feici02 merged commit 77cda04 into 3.0 Oct 24, 2025
5 of 6 checks passed
@feici02 feici02 deleted the fix/huoh/TD-38281-3.0 branch October 24, 2025 10:30
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.

2 participants