Skip to content

tests: fix next gen integration TiDB startup flakiness#4278

Open
wlwilliamx wants to merge 1 commit intopingcap:masterfrom
wlwilliamx:fix/next-gen-start-tidb-cluster-fail
Open

tests: fix next gen integration TiDB startup flakiness#4278
wlwilliamx wants to merge 1 commit intopingcap:masterfrom
wlwilliamx:fix/next-gen-start-tidb-cluster-fail

Conversation

@wlwilliamx
Copy link
Collaborator

@wlwilliamx wlwilliamx commented Feb 26, 2026

What problem does this PR solve?

Issue Number: close #4277

What is changed and how it works?

  • Fix next-gen TiDB config generation in integration test utils:
    • Keep socket and max-server-connections at root level.
    • Keep run-auto-analyze / server-memory-quota under [performance] so TiDB won't treat them as invalid options.
  • Ensure stop_tidb_cluster kills leaked cdc_pulsar_consumer to avoid accumulating background processes across cases/groups.

Check List

Tests

  • Integration test
  • Manual test
bash -n tests/integration_tests/_utils/start_tidb_cluster_nextgen
bash -n tests/integration_tests/_utils/start_tls_tidb_cluster_impl_nextgen
bash -n tests/integration_tests/_utils/stop_tidb_cluster

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

None

Summary by CodeRabbit

  • Tests

    • Improved cluster configuration validation to prevent invalid configuration options.
    • Enhanced TLS security settings for test deployments.
  • Chores

    • Refined cleanup procedures to prevent resource leaks across test cases.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. labels Feb 26, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 26, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign lidezhu for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 26, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @wlwilliamx, 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 addresses flakiness in next-gen TiDB integration tests by rectifying issues in how TiDB configuration files are generated and by improving test environment cleanup. The changes ensure that TiDB starts reliably by adhering to its configuration parsing rules and prevent background processes from accumulating, leading to more stable and predictable test runs.

Highlights

  • TiDB Configuration Fixes: Corrected TiDB configuration generation in integration tests to properly place socket and max-server-connections at the root level, and relocated performance-related configurations (run-auto-analyze, server-memory-quota) to the [performance] section to ensure they are correctly parsed.
  • Test Environment Cleanup: Enhanced the stop_tidb_cluster utility to terminate cdc_pulsar_consumer processes, preventing resource leaks and improving test stability.

🧠 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
  • tests/integration_tests/_utils/start_tidb_cluster_nextgen
    • Updated the randomGenSocketsConf function to prepend the socket configuration at the root level of the TiDB config file and remove any existing socket entries.
    • Added a comment explaining the section-sensitive nature of TiDB config keys.
    • Moved max-server-connections from the [instance] section to the root level.
    • Moved run-auto-analyze and server-memory-quota from the root level to the [performance] section.
  • tests/integration_tests/_utils/start_tls_tidb_cluster_impl_nextgen
    • Added a comment explaining the section-sensitive nature of TiDB config keys.
    • Moved max-server-connections from the [instance] section to the root level.
    • Moved run-auto-analyze and server-memory-quota from the root level to the [performance] section.
  • tests/integration_tests/_utils/stop_tidb_cluster
    • Added cdc_pulsar_consumer to the list of processes to be killed during cluster shutdown.
Activity
  • No specific activity (comments, reviews, or progress updates) was provided in the 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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5129f10 and 76bb15b.

📒 Files selected for processing (3)
  • tests/integration_tests/_utils/start_tidb_cluster_nextgen
  • tests/integration_tests/_utils/start_tls_tidb_cluster_impl_nextgen
  • tests/integration_tests/_utils/stop_tidb_cluster

📝 Walkthrough

Walkthrough

The changes fix configuration key placement issues in TiDB/TiKV config generation for next-gen integration tests and add process cleanup. They reorganize options between root and section levels, rework socket configuration handling, expand TLS settings, and introduce consumer process termination in cluster shutdown to prevent resource leaks.

Changes

Cohort / File(s) Summary
TiDB next-gen config generation
tests/integration_tests/_utils/start_tidb_cluster_nextgen
Reworked socket configuration to prepend at root level and remove stray socket lines using temporary file strategy. Reorganized TiDB/TiKV options (max-server-connections, server-memory-quota, run-auto-analyze) to correct TOML sections per TiDB validation requirements. Added explanatory comments on section-sensitive key placement.
TLS TiDB config generation
tests/integration_tests/_utils/start_tls_tidb_cluster_impl_nextgen
Moved tuning options from root to [performance] section for tidb-system-config-tls.toml. Introduced explicit TLS/security fields (ssl-ca, ssl-cert, ssl-key, cluster-ssl-ca, cluster-ssl-cert, cluster-ssl-key) under [security]. Updated per-keyspace config to add root-level max-server-connections and ensure consistent TLS field placement.
Cluster shutdown cleanup
tests/integration_tests/_utils/stop_tidb_cluster
Added termination of cdc_pulsar_consumer process during cluster shutdown with descriptive comment explaining need to prevent sink consumer process leaks across test cases.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

Suggested labels

lgtm, approved

Suggested reviewers

  • lidezhu
  • asddongmen
  • wk989898

Poem

🐰 Config files now dance in proper place,
Root keys and sections find their space,
No sockets stray, no leaks remain,
TLS fields add to the gain,
Tests flow clean, no more pain! 🔐

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'tests: fix next gen integration TiDB startup flakiness' clearly and concisely summarizes the main change—fixing integration test utilities to resolve TiDB startup issues in next-gen environments.
Description check ✅ Passed The description covers all required sections: problem statement (Issue #4277), changes made with technical details, test verification (integration and manual), and release notes (None).
Linked Issues check ✅ Passed The PR directly addresses both root causes from issue #4277: invalid TiDB config generation (socket, max-server-connections, performance section options) and process leak (cdc_pulsar_consumer cleanup in stop_tidb_cluster).
Out of Scope Changes check ✅ Passed All changes are strictly focused on fixing the two identified issues: TiDB config generation and process cleanup. No extraneous or unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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 addresses flakiness in next-generation integration tests by correcting TiDB configuration generation and improving the test cleanup process. The changes relocate TiDB configuration options to their proper sections within the TOML files, and fix the socket configuration generation to ensure it's a root-level setting. Furthermore, the stop_tidb_cluster script is updated to kill leftover cdc_pulsar_consumer processes, preventing resource leaks between test executions. I have one minor suggestion to enhance the robustness of temporary file creation in a shell script.

Comment on lines +32 to +33
} >"$config_file.tmp"
mv "$config_file.tmp" "$config_file"

Choose a reason for hiding this comment

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

medium

Using a fixed temporary filename like .tmp can be problematic if multiple instances of this script run concurrently. To make the temporary filename unique and avoid potential race conditions, consider appending the process ID ($$). A more robust solution would be to use mktemp.

	} >"$config_file.tmp.$$"
	mv "$config_file.tmp.$$" "$config_file"

@wlwilliamx
Copy link
Collaborator Author

/test pull-cdc-pulsar-light-integration-test-next-gen

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 26, 2026

@wlwilliamx: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

/test pull-build
/test pull-cdc-kafka-integration-heavy
/test pull-cdc-kafka-integration-light
/test pull-cdc-mysql-integration-heavy
/test pull-cdc-mysql-integration-light
/test pull-cdc-storage-integration-heavy
/test pull-cdc-storage-integration-light
/test pull-check
/test pull-error-log-review
/test pull-unit-test

The following commands are available to trigger optional jobs:

/test pull-build-next-gen
/test pull-cdc-kafka-integration-heavy-next-gen
/test pull-cdc-kafka-integration-light-next-gen
/test pull-cdc-mysql-integration-heavy-next-gen
/test pull-cdc-mysql-integration-light-next-gen
/test pull-cdc-pulsar-integration-heavy
/test pull-cdc-pulsar-integration-heavy-next-gen
/test pull-cdc-pulsar-integration-light
/test pull-cdc-pulsar-integration-light-next-gen
/test pull-cdc-storage-integration-heavy-next-gen
/test pull-cdc-storage-integration-light-next-gen
/test pull-unit-test-next-gen

Use /test all to run the following jobs that were automatically triggered:

pull-error-log-review
Details

In response to this:

/test pull-cdc-pulsar-light-integration-test-next-gen

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@wlwilliamx
Copy link
Collaborator Author

/test pull-cdc-pulsar-integration-light-next-gen

@wlwilliamx
Copy link
Collaborator Author

/test pull-cdc-pulsar-integration-heavy-next-gen

@tenfyzhong
Copy link
Collaborator

/test next-gen

3 similar comments
@wlwilliamx
Copy link
Collaborator Author

/test next-gen

@wlwilliamx
Copy link
Collaborator Author

/test next-gen

@wlwilliamx
Copy link
Collaborator Author

/test next-gen

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 27, 2026

@wlwilliamx: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cdc-storage-integration-heavy-next-gen 76bb15b link false /test pull-cdc-storage-integration-heavy-next-gen
pull-cdc-pulsar-integration-heavy-next-gen 76bb15b link false /test pull-cdc-pulsar-integration-heavy-next-gen

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests/integration: pulsar next gen jobs fail to start TiDB (process leak + invalid TiDB config)

2 participants