Skip to content

Conversation

@tomchon
Copy link
Contributor

@tomchon tomchon commented Jan 5, 2026

Copilot AI review requested due to automatic review settings January 5, 2026 12:02
@tomchon tomchon requested a review from a team as a code owner January 5, 2026 12:02
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tomchon, 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 framework by introducing a robust mechanism to verify that all database transactions are cleared following the creation of a new database. This is achieved through a new utility function that actively waits for transaction completion, which is then integrated into the database creation process. Additionally, a relevant test case has been activated in the CI pipeline to leverage this new functionality.

Highlights

  • New Utility Function: A new utility method, waitTransactionZeroWithTsql, has been added to tmqUtil.py. This function polls the system to ensure that all active transactions have completed before proceeding, with a timeout of 300 seconds.
  • Transaction Check After Database Creation: The newly introduced waitTransactionZeroWithTsql method is now invoked immediately after a new database is created within the create_database function in tmqUtil.py. This ensures that no pending transactions remain after database initialization.
  • Test Case Update: The win_cases.task CI configuration has been updated to enable and run the test_tmq_snapshot_basic.py pytest case, replacing a previously commented-out test.

🧠 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.

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 aims to fix a race condition by waiting for transactions to complete after creating a database. The approach is sound, but there are a couple of areas for improvement.

The new waitTransactionZeroWithTsql method should be made more robust by explicitly handling timeouts to prevent silent test failures. I've provided a suggestion to improve its implementation.

More critically, the new test case enabled in this PR (test_tmq_snapshot_basic.py) does not actually use the new fix. It calls tdCom.create_database instead of tmqCom.create_database, so the waiting logic is never executed for this test. This needs to be corrected to ensure the fix is effective and properly tested.

Lastly, there's a small typo in the pull request title ('transcation' should be 'transaction').

Comment on lines 40 to 49
def waitTransactionZeroWithTsql(self, tsql):
for i in range(300):
sql ="show transactions;"
tsql.execute(sql)
result = tsql.fetchall()
rows = len(result)
if rows == 0:
tdLog.info("transaction count became zero.")
return True
time.sleep(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This new method can be improved for clarity, robustness, and configurability:

  • Timeout Handling: The current implementation implicitly returns None if the loop completes, which could lead to silent failures in tests. It's better to explicitly handle the timeout, for instance by calling tdLog.exit() which seems to be the standard way to fail tests in this project.
  • Readability: The loop variable i is unused and can be replaced with _. The check for an empty result can be made more Pythonic (if not result:). Also, the spacing in sql ="show transactions;" is unconventional.
  • Configurability: The timeout duration is hardcoded. Making it a parameter with a default value would be more flexible.

Here is a suggested refactoring that addresses these points:

Suggested change
def waitTransactionZeroWithTsql(self, tsql):
for i in range(300):
sql ="show transactions;"
tsql.execute(sql)
result = tsql.fetchall()
rows = len(result)
if rows == 0:
tdLog.info("transaction count became zero.")
return True
time.sleep(1)
def waitTransactionZeroWithTsql(self, tsql, timeout=300):
for _ in range(timeout):
sql = "show transactions;"
tsql.execute(sql)
result = tsql.fetchall()
if not result:
tdLog.info("transaction count became zero.")
return True
time.sleep(1)
tdLog.exit(f"Timeout after {timeout} seconds waiting for transaction count to become zero.")

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 adds a transaction monitoring mechanism to ensure transactions complete before proceeding after database creation. The title contains a spelling error: "transcation" should be "transaction".

Key Changes:

  • Introduces waitTransactionZeroWithTsql method to poll for zero active transactions
  • Integrates the transaction check into the create_database method
  • Enables a previously commented-out test case for TMQ snapshot functionality

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
test/new_test_framework/utils/tmqUtil.py Adds transaction wait utility method and integrates it into database creation to ensure clean state
test/ci/win_cases.task Uncomments and updates test case from tmqConsFromTsdb to test_tmq_snapshot_basic.py

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


def waitTransactionZeroWithTsql(self, tsql):
for i in range(300):
sql ="show transactions;"
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

Missing space after the assignment operator. The line should be formatted as 'sql = "show transactions;"' with a space after the equals sign to maintain consistent code style throughout the file.

Suggested change
sql ="show transactions;"
sql = "show transactions;"

Copilot uses AI. Check for mistakes.
@tomchon tomchon changed the title Fix/add check transcation after new db fix:add check transcation after new db Jan 7, 2026
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.

3 participants