8000 dispatcher: fix the bug during remove dispatcher by hongyunyan · Pull Request #1364 · pingcap/ticdc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dispatcher: fix the bug during remove dispatcher #1364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
May 29, 2025

Conversation

hongyunyan
Copy link
Collaborator
@hongyunyan hongyunyan commented May 23, 2025

What problem does this PR solve?

Issue Number: close #1356

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

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

Release note

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 23, 2025
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.

Hello @hongyunyan, 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!

Summary of Changes

Hello! Gemini here, providing a summary of this pull request to help everyone get up to speed quickly.

This PR, marked as '[WIP]', appears to be focused on testing scenarios related to the MySQL sink's batch DML functionality, specifically when batching is not used (batch_update_to_no_batch). The primary functional changes involve modifying the logic that determines whether batch SQL should be generated for DML events in the MySQL sink. Additionally, the PR includes changes to the CI configuration to repeatedly run the batch_update_to_no_batch integration test, likely to thoroughly test this specific scenario.

There are also minor logging adjustments in the dispatcher and maintainer components.

Highlights

  • MySQL Sink Batching Logic: The core logic in pkg/sink/mysql/mysql_writer_dml.go that decides whether to generate batch SQL (shouldGenBatchSQL) has been modified. The function now accepts the full Config object instead of just the safemode boolean, allowing for more configuration-driven decisions about batching. Comments and commented-out code suggest potential future logic based on BatchDMLEnable.
  • CI Test Configuration: The CI configuration script tests/integration_tests/run_light_it_in_ci.sh has been updated to replace many existing test entries with repeated runs of the batch_update_to_no_batch integration test across multiple groups. This indicates a focused effort to test this specific scenario extensively.
  • Logging Improvements: Minor logging changes were made in downstreamadapter/dispatcher/helper.go and maintainer/barrier.go to provide more specific information in log messages.

Changelog

Click here to see the changelog
  • downstreamadapter/dispatcher/helper.go
    • Modified log message in Set function to print taskDispatcherID instead of the full task object (line 49).
  • maintainer/barrier.go
    • Added a new log message "hyy handle block status send dispatcher status" including dispatcherStatus in the HandleStatus function (line 165).
  • pkg/sink/mysql/mysql_writer_dml.go
    • Updated the call to shouldGenBatchSQL in prepareDMLs to pass the w.cfg object instead of just w.cfg.SafeMode (line 75).
    • Changed the signature of shouldGenBatchS 8000 QL to accept *Config instead of a boolean safemode (line 99).
    • Updated comments and added commented-out code in shouldGenBatchSQL related to BatchDMLEnable and event length checks (lines 94-106).
    • Modified the call to allRowInSameSafeMode within shouldGenBatchSQL to use cfg.SafeMode (line 116).
  • tests/integration_tests/run_light_it_in_ci.sh
    • Replaced most entries in the mysql_groups array with repeated occurrences of the batch_update_to_no_batch test name (lines 35-65).
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


Code changes arrive,
Tests run to make sure they thrive,
Batching logic shifts.

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
@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 PR appears to be a work-in-progress, focusing on testing the batch_update_to_no_batch functionality. The changes primarily involve modifications to logging, conditional logic for batch SQL generation, and significant alterations to the CI test script for MySQL integration tests.

Key areas to address before this PR moves out of WIP status:

  • The PR description (Issue Number, What is changed, Tests, Questions, Release note) needs to be thoroughly filled out.
  • Temporary/debug code (like specific log prefixes or commented-out logic) should be cleaned up.
  • The CI test script modifications must be reverted to ensure full test coverage is restored.

Overall, the direction seems clear for testing a specific feature. Good job isolating the test case in the CI script for focused testing during development!

Summary of Findings

  • CI Test Script Modification: The run_light_it_in_ci.sh script has been modified to run only the batch_update_to_no_batch test for all MySQL groups. This must be reverted before final merge.
  • Temporary Debug Log: A log message with a personal prefix "hyy" was found in maintainer/barrier.go. This should be removed or standardized.
  • Commented-Out Logic: In pkg/sink/mysql/mysql_writer_dml.go, there's commented-out logic related to BatchDMLEnable and single event checks. The BatchDMLEnable check might need to be uncommented, and the single event check appears redundant.
  • Logging Improvement (Not Commented): In downstreamadapter/dispatcher/helper.go, changing the logging of the task object to task.dispatcher.id is a good improvement for conciseness. This was not commented on directly due to review severity settings.

Merge Readiness

This pull request is currently a Work-In-Progress and is not ready for merging. Several critical and medium severity issues need to be addressed:

  1. The CI test script (tests/integration_tests/run_light_it_in_ci.sh) modifications must be reverted to ensure full test coverage.
  2. Temporary debug logs (e.g., in maintainer/barrier.go) should be removed.
  3. Commented-out logic in pkg/sink/mysql/mysql_writer_dml.go needs clarification and potential uncommenting/cleanup.
  4. The pull request description, including issue numbers and release notes, needs to be completed.

I recommend addressing these points before the PR is considered for merging. As an AI, I am not authorized to approve pull requests; please ensure other human reviewers approve this code before merging.

Comment on lines 35 to 65
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G01
'common_1 foreign_key changefeed_pause_resume fail_over_ddl_B'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G02
'new_ci_collation safe_mode savepoint fail_over_ddl_C'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G03
'capture_suicide_while_balance_table kv_client_stream_reconnect fail_over_ddl_D'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G04
'ci_collation_compatibility multi_capture resourcecontrol fail_over_ddl_E'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G05
'vector simple partition_table fail_over_ddl_F'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G06
'http_api http_api_tls ddl_wait fail_over_ddl_G'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G07
'http_api_tls_with_user_auth fail_over_ddl_H'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G08
'capture_session_done_during_task changefeed_dup_error_restart mysql_sink_retry fail_over_ddl_I'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G09
'cdc_server_tips ddl_sequence server_config_compatibility fail_over_ddl_J'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G10
'changefeed_error bdr_mode fail_over_ddl_K'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G11
'multi_tables_ddl ddl_attributes multi_cdc_cluster fail_over_ddl_L'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G12
'row_format tiflash multi_rocks fail_over_ddl_M'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G13
'cli_tls_with_auth cli_with_auth fail_over_ddl_N'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G14
'batch_add_table batch_update_to_no_batch fail_over_ddl_O'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'
# G15
'split_region changefeed_resume_with_checkpoint_ts autorandom gc_safepoint'
'batch_update_to_no_batch batch_update_to_no_batch batch_update_to_no_batch'

Choose a reason for hiding this comment

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

critical

This change replaces all MySQL integration test groups with repetitions of batch_update_to_no_batch. While this is understandable for focused testing in a WIP PR, it's critical that this is reverted before merging the final PR to ensure all other MySQL integration tests are executed. Please make a note to restore the original test groups.

@@ -161,6 +161,8 @@ func (b *Barrier) HandleStatus(from node.ID,
zap.String("changefeed", request.ChangefeedID.String()))
return nil
}

log.Info("hyy handle block status send dispatcher status", zap.Any("dispatcherStatus", dispatcherStatus))

Choose a reason for hiding this comment

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

medium

This log message with the prefix "hyy" seems like a temporary debug statement. Could you please remove this log line if it's only for debugging purposes, or update the message to be more descriptive and remove the prefix if it's intended to be a permanent log?

Comment on lines 100 to 106
// if !cfg.BatchDMLEnable {
// return false
// }

// if len(events) == 1 && events[0].Len() == 1 {
// return false
// }

Choose a reason for hiding this comment

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

medium

There's some commented-out logic here.

  1. The condition !cfg.BatchDMLEnable (lines 100-102) aligns with the updated function comment: "1. BatchDMLEnable = true, and rows > 1". Should this be uncommented to enforce this check?
  2. The condition len(events) == 1 && events[0].Len() == 1 (lines 104-106) appears to be redundant, as this exact check is already active later in the function at lines 108-110 (previously lines 112-114 in the diff).

Could you clarify the intent here? If the BatchDMLEnable check is needed, it should be uncommented. The redundant check for single row events should probably be removed from this commented block.

	if !cfg.BatchDMLEnable {
		return false
	}

	// The following check is redundant as it's handled below.
	// if len(events) == 1 && events[0].Len() == 1 {
	// 	return false
	// }

Copy link
ti-chi-bot bot commented May 23, 2025

@gemini-code-assist[bot]: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Code Review

This PR appears to be a work-in-progress, focusing on testing the batch_update_to_no_batch functionality. The changes primarily involve modifications to logging, conditional logic for batch SQL generation, and significant alterations to the CI test script for MySQL integration tests.

Key areas to address before this PR moves out of WIP status:

  • The PR description (Issue Number, What is changed, Tests, Questions, Release note) needs to be thoroughly filled out.
  • Temporary/debug code (like specific log prefixes or commented-out logic) should be cleaned up.
  • The CI test script modifications must be reverted to ensure full test coverage is restored.

Overall, the direction seems clear for testing a specific feature. Good job isolating the test case in the CI script for focused testing during development!

Summary of Findings

  • CI Test Script Modification: The run_light_it_in_ci.sh script has been modified to run only the batch_update_to_no_batch test for all MySQL groups. This must be reverted before final merge.
  • Temporary Debug Log: A log message with a personal prefix "hyy" was found in maintainer/barrier.go. This should be removed or standardized.
  • Commented-Out Logic: In pkg/sink/mysql/mysql_writer_dml.go, there's commented-out logic related to BatchDMLEnable and single event checks. The BatchDMLEnable check might need to be uncommented, and the single event check appears redundant.
  • Logging Improvement (Not Commented): In downstreamadapter/dispatcher/helper.go, changing the logging of the task object to task.dispatcher.id is a good improvement for conciseness. This was not commented on directly due to review severity settings.

Merge Readiness

This pull request is currently a Work-In-Progress and is not ready for merging. Several critical and medium severity issues need to be addressed:

  1. The CI test script (tests/integration_tests/run_light_it_in_ci.sh) modifications must be reverted to ensure full test coverage.
  2. Temporary debug logs (e.g., in maintainer/barrier.go) should be removed.
  3. Commented-out logic in pkg/sink/mysql/mysql_writer_dml.go needs clarification and potential uncommenting/cleanup.
  4. The pull request description, including issue numbers and release notes, needs to be completed.

I recommend addressing these points before the PR is considered for merging. As an AI, I am not authorized to approve pull requests; please ensure other human reviewers approve this code before merging.

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.

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 27, 2025
@hongyunyan
Copy link
Collaborator Author

/retest

@hongyunyan
Copy link
Collaborator Author

/test help

Copy link
ti-chi-bot bot commented May 27, 2025

@hongyunyan: 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-unit-test

The following commands are available to trigger optional jobs:

/test pull-cdc-pulsar-integration-light

Use /test all to run all jobs.

In response to this:

/test help

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.

@hongyunyan
Copy link
Collaborator Author

/test all

@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 27, 2025
@hongyunyan hongyunyan changed the title [WIP] Test batch_update_to_no_batch dispatcher: fix the bug during remove dispatcher May 27, 2025
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-linked-issue labels May 27, 2025
@ti-chi-bot ti-chi-bot bot added the lgtm label May 27, 2025
Copy link
ti-chi-bot bot commented May 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: asddongmen

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

The pull request process is described here

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 approved label May 27, 2025
Copy link
ti-chi-bot bot commented May 27, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-05-27 08:59:06.603334088 +0000 UTC m=+345876.975121550: ☑️ agreed by asddongmen.

@hongyunyan
Copy link
Collaborator Author

@gemini-code-assist

Copy link

Hello @hongyunyan,

Thanks for tagging me. I've reviewed the latest changes in this pull request.

The patches primarily focus on refining the dispatcher closing logic in downstreamadapter/dispatcher/dispatcher.go and downstreamadapter/dispatchermanager/event_dispatcher_manager.go, improving logging in downstreamadapter/dispatcher/helper.go, and adjusting the batch SQL generation condition in pkg/sink/mysql/mysql_writer_dml.go.

I noticed that the temporary debug log I mentioned in my initial review (Comment 1) in downstreamadapter/dispatcher/helper.go has been addressed in these patches, which is great. The commented-out logic related to BatchDMLEnable in pkg/sink/mysql/mysql_writer_dml.go also appears to have been incorporated into the shouldGenBatchSQL function logic.

However, my previous review also highlighted two other important points:

  1. CI Test Script Modification: The tests/integration_tests/run_light_it_in_ci.sh script was modified to run only a specific test. This should be reverted to ensure full test coverage before merging.
  2. Incomplete PR Description: The pull request description still needs to be thoroughly filled out, including details on what was changed, how it works, and release notes.

Additionally, I see that some tests failed after the /test all command (Comment 6). It would be beneficial to investigate these failures to ensure the changes haven't introduced regressions.

I see that the PR has been approved and LGTM'd. Please consider addressing the remaining points regarding the CI script, PR description, and test failures before merging to ensure the highest quality.

Let me know if you have any further questions!

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 27, 2025
@hongyunyan
Copy link
Collaborator Author

/retest

@hongyunyan
Copy link
Collaborator Author

/test pull-cdc-mysql-integration-heavy

@hongyunyan
Copy link
Collaborator Author

//run-check-issue-triage-complete

@hongyunyan
Copy link
Collaborator Author

/run-check-issue-triage-complete

Copy link
ti-chi-bot bot commented May 29, 2025

@hongyunyan: The following test 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-pulsar-integration-light de5c97f link false /test pull-cdc-pulsar-integration-light

Full PR test history. Your PR dashboard.

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.

@ti-chi-bot ti-chi-bot bot merged commit 12951e1 into pingcap:master May 29, 2025
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unstable intergration test of batch_update_to_no_batch
2 participants
0