Skip to content

Conversation

lidezhu
Copy link
Collaborator

@lidezhu lidezhu commented Jul 3, 2025

What problem does this PR solve?

Issue Number: close #12206

What is changed and how it works?

Evaluate and fill the value of virtual columns before evaluate the expression on the row.

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 evaluating event-filter expressions on tables with virtual columns.

@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. area/dm Issues or PRs related to DM. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 3, 2025
@lidezhu lidezhu changed the title eventfilter: fix crash when evaluate expressions for table with virtual columns eventfilter: fix panic when evaluate expressions for table with virtual columns Jul 3, 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 @lidezhu, 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 resolves a critical crash that occurred when evaluating event filter expressions for tables containing virtual columns. The core issue stemmed from the expression evaluation engine not correctly receiving the computed values for these derived columns. The changes introduce robust mechanisms to precisely identify, store offsets for, and dynamically compute virtual column values, ensuring that expressions are evaluated against a complete and accurate representation of the row data. This prevents crashes and enables reliable filtering for tables with virtual columns.

Highlights

  • Enhanced Virtual Column Handling: The TableInfo structure has been refactored to store explicit offsets of virtual columns (VirtualColumnsOffset) instead of just a count. This provides more precise metadata for handling these columns throughout the system.
  • Row Data Reconstruction: New methods (getDatumsWithVirtualCols, GetRowDatumsWithVirtualCols, GetPreRowDatumsWithVirtualCols) have been introduced in RowChangedDatums to dynamically reconstruct row data. This process inserts placeholders for virtual columns at their correct positions, preparing the data for expression evaluation.
  • Dynamic Virtual Column Computation: Logic within the expression filter (buildRowWithVirtualColumns) now computes and fills the values of virtual columns into the row data before expression evaluation. This ensures that filter expressions can correctly reference and use these derived values, preventing crashes and ensuring accurate filtering.
  • Improved Data Casting: The AdjustBinaryProtocolForDatum utility has been updated to correctly align incoming data (which typically lacks virtual columns) with the full table schema. It achieves this by skipping non-CDC visible columns during the casting process, ensuring data integrity.
  • Comprehensive Test Coverage: A dedicated test case has been added for tables with virtual columns in expr_filter_test.go. This new test validates the correct behavior of event filtering with expressions that involve virtual columns, confirming the fix.
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

The pull request addresses a critical issue related to virtual columns. The changes are well-structured and include a new test case. I've provided suggestions to improve thread safety and logging.

Copy link

codecov bot commented Jul 3, 2025

Codecov Report

Attention: Patch coverage is 65.85366% with 28 lines in your changes missing coverage. Please review.

Project coverage is 55.0649%. Comparing base (ac2fcf4) to head (42cb6b1).
Report is 1 commits behind head on master.

Additional details and impacted files
Components Coverage Δ
cdc 59.3064% <65.8536%> (+0.0176%) ⬆️
dm 50.0968% <ø> (-0.0269%) ⬇️
engine 53.2223% <ø> (-0.0057%) ⬇️
Flag Coverage Δ
unit 55.0649% <65.8536%> (ø)

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

@@             Coverage Diff             @@
##             master     #12211   +/-   ##
===========================================
  Coverage   55.0649%   55.0649%           
===========================================
  Files          1030       1030           
  Lines        143487     143556   +69     
===========================================
+ Hits          79011      79049   +38     
- Misses        58669      58691   +22     
- Partials       5807       5816    +9     
🚀 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 size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 3, 2025
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 3, 2025
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/needs-linked-issue labels Jul 3, 2025
@lidezhu lidezhu changed the title eventfilter: fix panic when evaluate expressions for table with virtual columns event filter: fix panic when evaluate expressions for table with virtual columns Jul 3, 2025
@lidezhu lidezhu removed the area/dm Issues or PRs related to DM. label Jul 3, 2025
Copy link
Contributor

ti-chi-bot bot commented Jul 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: asddongmen, hongyunyan

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:
  • OWNERS [asddongmen,hongyunyan]

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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 7, 2025
Copy link
Contributor

ti-chi-bot bot commented Jul 7, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-07-07 07:48:35.370760909 +0000 UTC m=+1899568.093939888: ☑️ agreed by asddongmen.
  • 2025-07-07 12:46:44.210020836 +0000 UTC m=+1917456.933199817: ☑️ agreed by hongyunyan.

@ti-chi-bot ti-chi-bot bot merged commit b144e40 into master Jul 7, 2025
28 checks passed
@ti-chi-bot ti-chi-bot bot deleted the ldz/fix-expr-filter branch July 7, 2025 12:52
ti-chi-bot pushed a commit to ti-chi-bot/tiflow that referenced this pull request Jul 7, 2025
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #12216.
But this PR has conflicts, please resolve them!

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #12217.
But this PR has conflicts, please resolve them!

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #12218.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.5: #12219.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #12220.
But this PR has conflicts, please resolve them!

ti-chi-bot bot pushed a commit that referenced this pull request Jul 10, 2025
ti-chi-bot bot pushed a commit that referenced this pull request Jul 10, 2025
ti-chi-bot bot pushed a commit that referenced this pull request Jul 10, 2025
ti-chi-bot bot pushed a commit that referenced this pull request Jul 10, 2025
ti-chi-bot bot pushed a commit that referenced this pull request Jul 10, 2025
lidezhu pushed a commit that referenced this pull request Jul 17, 2025
lidezhu pushed a commit that referenced this pull request Jul 25, 2025
lidezhu added a commit that referenced this pull request Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/dm Issues or PRs related to DM. area/ticdc Issues or PRs related to TiCDC. lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. 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.

TiCDC crashes when the ignore_insert_value_expr configuration is enabled for tables containing virtual columns.
4 participants