Skip to content

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #12254

What problem does this PR solve?

Issue Number: close #12241

What is changed and how it works?

Since column values don't include virtual generated columns, we also filter the virtual generated columns in the column dispatcher.
The column dispatcher now explicitly checks for and prevents the use of virtual generated columns, returning an ErrDispatcherFailed error if such columns are specified. This prevents potential panics when configuring the dispatcher.

Check List

Tests

  • Unit test
  • Integration test

Questions

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

Release note

Fix panic when configuring the column dispatcher with virtual columns.

@ti-chi-bot ti-chi-bot added lgtm 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Jul 18, 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.

Summary of Changes

Hello @ti-chi-bot, 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 critical issue where the column dispatcher could panic when attempting to use virtual generated columns. The changes introduce robust error handling within the OffsetsByNames function and related dispatcher components, ensuring that any attempt to dispatch events using virtual columns or non-existent columns results in a controlled error rather than a crash.

Highlights

  • Enhanced Column Dispatcher Safety: The OffsetsByNames function in TableInfo now explicitly checks for and rejects virtual generated columns, returning a specific error (ErrDispatcherFailed) if such columns are encountered. This prevents potential panics.
  • Improved Error Handling: The OffsetsByNames function's signature has been updated from returning a boolean ok to returning an error, allowing for more detailed error reporting when columns are not found or are virtual generated columns.
  • Propagated Error Checks: Downstream components, specifically EventRouter and ColumnsDispatcher, have been updated to correctly handle and propagate the new error type returned by OffsetsByNames, ensuring graceful failure instead of panics.
  • Comprehensive Test Coverage: New test cases have been added and existing ones updated to validate the correct behavior when attempting to use virtual generated columns or non-existent columns, ensuring the dispatcher fails gracefully with appropriate error messages.
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.

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 fixes a potential panic by preventing the use of virtual columns in the column dispatcher. The OffsetsByNames function is updated to explicitly check for and reject virtual columns, returning a descriptive error instead of panicking. The function signature is changed to return an error instead of a bool, which improves error handling. New unit tests cover the virtual column and column-not-found error cases. A suggestion is made to restore a map capacity hint for a minor performance improvement.

func (ti *TableInfo) OffsetsByNames(names []string) ([]int, error) {
// todo: optimize it
columnOffsets := make(map[string]int, len(ti.Columns))
columnOffsets := make(map[string]int)

Choose a reason for hiding this comment

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

medium

Consider providing a capacity hint when initializing the columnOffsets map, as the approximate size is known (len(ti.Columns)). This can help avoid reallocations and improve performance slightly.

Suggested change
columnOffsets := make(map[string]int)
columnOffsets := make(map[string]int, len(ti.Columns))

Copy link

codecov bot commented Jul 18, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.5@2d8137b). Learn more about missing BASE report.

Additional details and impacted files
Components Coverage Δ
cdc 59.5816% <0.0000%> (?)
dm 50.1174% <0.0000%> (?)
engine 53.2110% <0.0000%> (?)
Flag Coverage Δ
unit 55.1636% <87.5000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

@@               Coverage Diff                @@
##             release-8.5     #12255   +/-   ##
================================================
  Coverage               ?   55.1636%           
================================================
  Files                  ?       1003           
  Lines                  ?     136831           
  Branches               ?          0           
================================================
  Hits                   ?      75481           
  Misses                 ?      55818           
  Partials               ?       5532           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot ti-chi-bot bot added the approved label Jul 18, 2025
Copy link
Contributor

ti-chi-bot bot commented Sep 12, 2025

@flowbehappy: adding LGTM is restricted to approvers and reviewers in OWNERS files.

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

Copy link
Contributor

ti-chi-bot bot commented Sep 12, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flowbehappy, wk989898

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 cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Sep 15, 2025
@ti-chi-bot ti-chi-bot bot merged commit 1ae56b1 into pingcap:release-8.5 Sep 15, 2025
21 of 26 checks passed
@ti-chi-bot ti-chi-bot bot deleted the cherry-pick-12254-to-release-8.5 branch September 15, 2025 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants