tests: fix next gen integration TiDB startup flakiness#4278
tests: fix next gen integration TiDB startup flakiness#4278wlwilliamx wants to merge 2 commits intopingcap:masterfrom
Conversation
Summary of ChangesHello @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
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
📝 WalkthroughWalkthroughFixes TiDB/TiKV TOML generation to place section-sensitive keys at correct root/section levels, expands TLS/security fields, prepends root-level socket lines, and adds termination of background cdc_pulsar_consumer to stop process leaks in integration test teardown. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
| } >"$config_file.tmp" | ||
| mv "$config_file.tmp" "$config_file" |
There was a problem hiding this comment.
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"
|
/test pull-cdc-pulsar-light-integration-test-next-gen |
|
@wlwilliamx: The specified target(s) for The following commands are available to trigger optional jobs: Use DetailsIn response to this:
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. |
|
/test pull-cdc-pulsar-integration-light-next-gen |
|
/test pull-cdc-pulsar-integration-heavy-next-gen |
|
/test next-gen |
3 similar comments
|
/test next-gen |
|
/test next-gen |
|
/test next-gen |
|
/retest |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tenfyzhong, wk989898 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
…t-tidb-cluster-fail # Conflicts: # tests/integration_tests/_utils/start_tidb_cluster_nextgen
|
/test all |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/integration_tests/_utils/start_tidb_cluster_nextgen (1)
365-471: Consider extracting common TiDB config generation into a helper function.The four TiDB config blocks share significant structure (root-level keys,
[log.file],[performance],[security]). A helper function accepting keyspace-name, tikv-worker-url, and service-scope as parameters could reduce duplication and ensure consistency. This is entirely optional given the current clarity.♻️ Example helper function approach
# Generate TiDB config with consistent structure gen_tidb_config() { local out_file="$1" local keyspace="$2" local tikv_worker_url="${3:-}" local service_scope="${4:-}" cat >"$out_file" <<EOF keyspace-name = "$keyspace" enable-telemetry = false mem-quota-query = 671088640 max-server-connections = 0 ${tikv_worker_url:+tikv-worker-url = "$tikv_worker_url"} [log.file] max-backups = 100 [performance] tcp-keep-alive = true run-auto-analyze = false server-memory-quota = 2684354560 [security] enable-sem = false ${service_scope:+ [instance] tidb_service_scope = '$service_scope'} EOF }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/integration_tests/_utils/start_tidb_cluster_nextgen` around lines 365 - 471, Multiple nearly identical TiDB config blocks (creating upstream/downstream and system/keyspace files) should be consolidated into a helper to avoid duplication; add a function (e.g., gen_tidb_config) that accepts parameters for out_file, keyspace-name, optional tikv-worker-url and optional service-scope and use it to replace the repeated cat >>"$OUT_DIR/…". Ensure the helper preserves existing behavior: append existing "$tidb_config" when present, create the target TEST_DATA_DIR directory, and conditionally include the tikv-worker-url line (use UP_TIKV_WORKER_HOST/UP_TIKV_WORKER_PORT or DOWN_TIKV_WORKER_HOST/DOWN_TIKV_WORKER_PORT) and the [instance]/tidb_service_scope entry when needed; then call this helper four times for upstream-system, upstream-keyspace, downstream-system, downstream-keyspace (and keep the cp of the other toml file).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@tests/integration_tests/_utils/start_tidb_cluster_nextgen`:
- Around line 365-471: Multiple nearly identical TiDB config blocks (creating
upstream/downstream and system/keyspace files) should be consolidated into a
helper to avoid duplication; add a function (e.g., gen_tidb_config) that accepts
parameters for out_file, keyspace-name, optional tikv-worker-url and optional
service-scope and use it to replace the repeated cat >>"$OUT_DIR/…". Ensure the
helper preserves existing behavior: append existing "$tidb_config" when present,
create the target TEST_DATA_DIR directory, and conditionally include the
tikv-worker-url line (use UP_TIKV_WORKER_HOST/UP_TIKV_WORKER_PORT or
DOWN_TIKV_WORKER_HOST/DOWN_TIKV_WORKER_PORT) and the
[instance]/tidb_service_scope entry when needed; then call this helper four
times for upstream-system, upstream-keyspace, downstream-system,
downstream-keyspace (and keep the cp of the other toml file).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8184c3dc-80ac-4cd7-add7-45abe3a6f77d
📒 Files selected for processing (3)
pkg/sink/sqlmodel/row_change_test.gotests/integration_tests/_utils/start_tidb_cluster_nextgentools/workload/schema/bank3/bank.go
✅ Files skipped from review due to trivial changes (1)
- tools/workload/schema/bank3/bank.go
|
@wlwilliamx: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
What problem does this PR solve?
Issue Number: close #4277
What is changed and how it works?
socketandmax-server-connectionsat root level.run-auto-analyze/server-memory-quotaunder[performance]so TiDB won't treat them as invalid options.stop_tidb_clusterkills leakedcdc_pulsar_consumerto avoid accumulating background processes across cases/groups.Check List
Tests
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note
Summary by CodeRabbit
Tests
Chores