Skip to content

maintainer: add mode information in barrier logs#4412

Open
hongyunyan wants to merge 3 commits intopingcap:masterfrom
hongyunyan:0309
Open

maintainer: add mode information in barrier logs#4412
hongyunyan wants to merge 3 commits intopingcap:masterfrom
hongyunyan:0309

Conversation

@hongyunyan
Copy link
Collaborator

@hongyunyan hongyunyan commented Mar 10, 2026

What problem does this PR solve?

Issue Number: close #4427

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/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 10, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 10, 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 flowbehappy 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

@gemini-code-assist
Copy link

Summary of Changes

Hello, 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 a logging deficiency in the maintainer's barrier system. Previously, barrier logs lacked replication mode information, making it difficult to differentiate between redo DDL handling and default table DDL paths. The changes introduce the replication mode into barrier event data and log outputs, providing crucial context for investigating barrier behavior and DDL execution.

Highlights

  • Barrier Mode Propagation: The barrier mode is now stored on BarrierEvent objects and passed through all relevant creation paths, ensuring its availability throughout the barrier lifecycle.
  • Enhanced Logging: Barrier logs in barrier.go and barrier_event.go have been updated to include the mode field, utilizing common.StringMode for clear identification of the replication mode.
  • Test Updates: Barrier event tests have been adjusted to accommodate the new constructor signature for NewBlockEvent, which now accepts the barrier mode.

🧠 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
  • maintainer/barrier.go
    • Added a modeField helper method to the Barrier struct for consistent logging of the barrier mode.
    • Modified HandleStatus, handleBootstrapResponse, handleEventDone, handleBlockState, getOrInsertNewEvent, checkEventFinish, and tryScheduleEvent methods to include the barrier mode in their log statements.
    • Updated calls to NewBlockEvent to pass the b.mode value.
  • maintainer/barrier_event.go
    • Added a mode field to the BarrierEvent struct.
    • Modified the NewBlockEvent constructor to accept and initialize the mode field.
    • Added a modeField helper method to the BarrierEvent struct for consistent logging.
    • Updated NewBlockEvent's internal logging to include the mode.
    • Modified createRangeCheckerForTypeAll, createRangeCheckerForTypeDB, onAllDispatcherReportedBlockEvent, scheduleBlockEvent, markDispatcherEventDone, allDispatcherReported, checkBlockedDispatchers, and resend methods to include the barrier mode in their log statements.
    • Updated a log.Panic call to include the barrier mode.
  • maintainer/barrier_event_test.go
    • Updated all calls to NewBlockEvent in test functions (TestScheduleEvent, TestResendAction, TestSendPassActionTypeDBIncludesWriterNode, TestUpdateSchemaID) to pass common.DefaultMode as the new mode parameter.
Activity
  • No human activity has been recorded on this pull request yet.
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.

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 10, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

The changes add a mode parameter to the barrier event creation flow and introduce enriched logging. A new helper method logs barrier modes, the NewBlockEvent function signature is expanded to accept a mode parameter, and all call sites are updated to pass the mode. Test cases are updated accordingly with no behavioral logic modifications.

Changes

Cohort / File(s) Summary
Barrier Mode Propagation
maintainer/barrier.go, maintainer/barrier_event.go
Added modeField() helper method and updated NewBlockEvent() signature to accept an additional mode int64 parameter. Mode is now logged throughout the barrier event lifecycle (creation, range checking, dispatch, blocking, resends, scheduling) for enhanced tracing and debugging.
Test Case Updates
maintainer/barrier_event_test.go
Updated all NewBlockEvent() call sites to pass common.DefaultMode as the final parameter, aligning test invocations with the updated function signature.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A mode field hops through logs so bright,
The barrier tracks each event's flight,
With enriched context, debugging's delight,
New parameters bloom in test and in sight,
Our logs now sparkle with detail just right! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The PR description is mostly empty. While it includes an issue number, the critical sections 'What is changed and how it works?', test selection, and release note are completely blank. Complete the 'What is changed and how it works?' section with a clear explanation, mark which tests were run, and provide a release note (or write 'None' if not applicable).
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'maintainer: add mode information in barrier logs' accurately describes the main change: adding mode context to barrier event logging for better troubleshooting of redo vs. default DDL paths.

✏️ 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

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 introduces logging of the replication mode in barrier events within the maintainer. This is a valuable addition for debugging, as it helps differentiate between the redo DDL path and the default DDL path. The implementation is clean and consistent: the mode is stored in BarrierEvent and passed through all creation paths. A new modeField helper method is used to add the mode to log entries, which improves code readability and maintainability. The tests have been updated to reflect these changes. The pull request is well-executed and I have no further recommendations.

@hongyunyan hongyunyan changed the title maintainer: add mode to barrier logs maintainer: add mode information in barrier logs Mar 10, 2026
@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 10, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 10, 2026

@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-error-log-review c8f729a link true /test pull-error-log-review

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

Add mode information in barrier to make debug easier

1 participant