Skip to content

Conversation

@hongyunyan
Copy link
Collaborator

@hongyunyan hongyunyan commented Nov 19, 2025

What problem does this PR solve?

Issue Number: ref #3178

What is changed and how it works?

  • Update table_count_range_checker_test.go to construct the checker with explicit table-ID slices, aligning the tests with the new TableIDRangeChecker API.
  • Downgrade useless log

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 release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 19, 2025
@gemini-code-assist
Copy link

Summary of Changes

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!

This pull request focuses on refining the DDL (Data Definition Language) barrier mechanism and its associated logging. It reduces log verbosity for routine operations, adjusts the resend intervals for certain tasks, and significantly enhances the precision of table ID tracking within the DDL barrier. These changes collectively aim to improve the clarity of system logs, optimize the timing of resend operations, and ensure more robust and accurate synchronization of DDL events, particularly in how the system manages and reports on table-specific events.

Highlights

  • Logging Verbosity Adjustment: Reduced the logging level from Info and Warn to Debug for several routine operations in basic_dispatcher.go and barrier.go. This change aims to declutter logs by making less critical messages only visible at higher debug levels.
  • Resend Task Interval Modification: The initial submission and subsequent execution intervals for ResendTask in helper.go have been standardized to 10 seconds. Additionally, the BarrierEvent.resend check interval was reduced from 10 seconds to 1 second, potentially allowing for quicker re-evaluation of resend conditions.
  • Enhanced Table ID Tracking in Range Checker: The TableIDRangeChecker in table_count_range_checker.go now directly tracks a slice of int64 table IDs instead of just a count. This allows for more precise monitoring and debugging, as the Detail() method can now list specific uncovered tables.
  • Refined Barrier Event Range Checker Logic: The logic for creating rangeChecker within barrier_event.go has been updated to leverage the enhanced NewTableCountChecker by passing actual table IDs. This applies to various methods like createRangeCheckerForTypeAll, createRangeCheckerForTypeDB, and allDispatcherReported, ensuring more accurate DDL barrier synchronization.
  • Test Suite Improvements: Test files (barrier_event_test.go, barrier_test.go, table_count_range_checker_test.go) have been updated. This includes uncommenting imports, refining assertions to handle multiple return messages, adding require.NotEmpty checks, and adjusting NewTableCountChecker calls to align with the new signature.
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

@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 primarily refines logging by reducing log levels from INFO/WARN to DEBUG in several places, which should help reduce log noise in production. It also includes a nice refactoring of TableCountChecker to provide more detailed debug messages, which aligns well with the goal of improving log messages. However, there are also some significant changes to the retry logic for DDL-related messages. While one change improves responsiveness, another one might introduce latency. I've added a few comments with suggestions for improvement.

callback: callback,
}
t.taskHandle = taskScheduler.Submit(t, time.Now().Add(50*time.Millisecond))
t.taskHandle = taskScheduler.Submit(t, time.Now().Add(resendTimeInterval))

Choose a reason for hiding this comment

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

high

The initial resend delay for this task has been increased from 50ms to 10 seconds. This is a significant change that could increase DDL processing latency if the first TableSpanBlockStatus message from the dispatcher to the maintainer is lost due to a transient network issue. Was this change intentional? A 10-second delay for the first retry seems quite long and could be perceived as a performance regression.


func (be *BarrierEvent) resend(mode int64) []*messaging.TargetMessage {
if time.Since(be.lastResendTime) < 10*time.Second {
if time.Since(be.lastResendTime) < time.Second {

Choose a reason for hiding this comment

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

medium

The resend interval is hardcoded here. It would be better to define this as a constant to improve maintainability and consistency, similar to how resendTimeInterval was introduced in downstreamadapter/dispatcher/helper.go.

For example, you could define a constant at the package level:

const barrierEventResendInterval = time.Second

Then use this constant here.

Comment on lines 58 to 73
func (rc *TableIDRangeChecker) Detail() string {
return fmt.Sprintf("reported count: %d, require count: %d", len(rc.reportedMap), rc.needCount)
buf := &strings.Builder{}
buf.WriteString("reported count: ")
buf.WriteString(strconv.FormatInt(int64(len(rc.reportedMap)), 10))
buf.WriteString(", require count: ")
buf.WriteString(strconv.FormatInt(int64(rc.needCount), 10))
buf.WriteString(", uncovered tables: ")
for _, id := range rc.tableIDs {
_, ok := rc.reportedMap[id]
if !ok {
buf.WriteString(fmt.Sprintf("%d,\n", id))
}
}

return buf.String()
}

Choose a reason for hiding this comment

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

medium

The enhanced Detail method is great for debugging! However, using fmt.Sprintf inside a loop can be inefficient. Also, the current implementation will leave a trailing comma and newline, and it will print , uncovered tables: even if there are no uncovered tables.

A more efficient and cleaner approach would be to collect the uncovered table IDs and then join them. This avoids repeated string formatting and the trailing separator.

func (rc *TableIDRangeChecker) Detail() string {
	buf := &strings.Builder{}
	buf.WriteString("reported count: ")
	buf.WriteString(strconv.FormatInt(int64(len(rc.reportedMap)), 10))
	buf.WriteString(", require count: ")
	buf.WriteString(strconv.FormatInt(int64(rc.needCount), 10))

	var uncoveredIDs []string
	for _, id := range rc.tableIDs {
		if _, ok := rc.reportedMap[id]; !ok {
			uncoveredIDs = append(uncoveredIDs, strconv.FormatInt(id, 10))
		}
	}

	if len(uncoveredIDs) > 0 {
		buf.WriteString(", uncovered tables: ")
		buf.WriteString(strings.Join(uncoveredIDs, ", "))
	}

	return buf.String()
}

@hongyunyan
Copy link
Collaborator Author

/test all

@hongyunyan
Copy link
Collaborator Author

/retest

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 20, 2025
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 20, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Nov 20, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-11-20 02:33:06.47183899 +0000 UTC m=+151750.121033447: ☑️ agreed by lidezhu.
  • 2025-11-20 02:41:52.983093256 +0000 UTC m=+152276.632287733: ☑️ agreed by asddongmen.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Nov 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: asddongmen, lidezhu, tenfyzhong

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [asddongmen,lidezhu,tenfyzhong]

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

@hongyunyan
Copy link
Collaborator Author

/retest

2 similar comments
@hongyunyan
Copy link
Collaborator Author

/retest

@hongyunyan
Copy link
Collaborator Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 3762eba into pingcap:master Nov 20, 2025
19 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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants