Skip to content

consumer: ignore stale event after renaming table in storage consumer#4871

Merged
ti-chi-bot[bot] merged 3 commits intopingcap:masterfrom
wk989898:storage-rename-fix
Apr 20, 2026
Merged

consumer: ignore stale event after renaming table in storage consumer#4871
ti-chi-bot[bot] merged 3 commits intopingcap:masterfrom
wk989898:storage-rename-fix

Conversation

@wk989898
Copy link
Copy Markdown
Collaborator

@wk989898 wk989898 commented Apr 20, 2026

What problem does this PR solve?

Issue Number: close #4334

What is changed and how it works?

Decode rename ddl query and update the old table name in tableDDLWatermark

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

Signed-off-by: wk989898 <nhsmwk@gmail.com>
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 20, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot Bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Apr 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

Warning

Rate limit exceeded

@wk989898 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 48 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 42cde888-4c4d-4403-9c68-e67564c906eb

📥 Commits

Reviewing files that changed from the base of the PR and between 0213a79 and 01417ce.

📒 Files selected for processing (1)
  • cmd/storage-consumer/consumer.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. do-not-merge/needs-triage-completed and removed do-not-merge/needs-linked-issue labels Apr 20, 2026
@wk989898 wk989898 marked this pull request as ready for review April 20, 2026 07:59
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 20, 2026
Copy link
Copy Markdown

@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 enhances the storage consumer to correctly handle table rename operations by updating DDL watermarks for both the old and new table identities. It introduces helper functions to parse DDL statements using the TiDB parser. Review feedback highlights the need to remove an unused regular expression and its corresponding import, and suggests adding safety checks to the type assertions and slice accesses during DDL parsing to avoid potential panics.

Comment thread cmd/storage-consumer/consumer.go Outdated
"context"
"encoding/json"
"fmt"
"regexp"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The regexp package is imported but only used for the renameTableQueryRe variable, which is itself unused. Since the implementation uses the TiDB parser instead, this import should be removed.

Comment thread cmd/storage-consumer/consumer.go Outdated
fakePartitionNumForSchemaFile = -1
)

var renameTableQueryRe = regexp.MustCompile(`(?is)^rename\s+table\s+(.+?)\s+to\s+(.+?)$`)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The renameTableQueryRe variable is unused. The logic in getRenameTableOldTableKey correctly uses the TiDB parser, which is a more reliable way to handle SQL statements. This variable should be removed.

Comment thread cmd/storage-consumer/consumer.go Outdated
wk989898 and others added 2 commits April 20, 2026 16:04
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Apr 20, 2026
@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 20, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 20, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-20 08:12:20.643141982 +0000 UTC m=+1980745.848502039: ☑️ agreed by 3AceShowHand.
  • 2026-04-20 08:27:13.863330224 +0000 UTC m=+1981639.068690281: ☑️ agreed by wlwilliamx.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 20, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3AceShowHand, flowbehappy, wlwilliamx

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 [3AceShowHand,flowbehappy,wlwilliamx]

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

@wk989898
Copy link
Copy Markdown
Collaborator Author

/retest

@ti-chi-bot ti-chi-bot Bot merged commit 8486a5d into pingcap:master Apr 20, 2026
17 of 26 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

storage consumer exits with 1146 after rename in storage integration

4 participants