-
Notifications
You must be signed in to change notification settings - Fork 293
sink(ticdc): check virtual columns in column dispatcher (#12254) #12255
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
sink(ticdc): check virtual columns in column dispatcher (#12254) #12255
Conversation
There was a problem hiding this 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 inTableInfo
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 booleanok
to returning anerror
, allowing for more detailed error reporting when columns are not found or are virtual generated columns. - Propagated Error Checks: Downstream components, specifically
EventRouter
andColumnsDispatcher
, have been updated to correctly handle and propagate the new error type returned byOffsetsByNames
, 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
-
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. ↩
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
columnOffsets := make(map[string]int) | |
columnOffsets := make(map[string]int, len(ti.Columns)) |
Codecov Report❌ Patch coverage is Additional details and impacted files
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:
|
@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. |
[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 |
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
Questions
Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?
Release note