Skip to content

consumer: skip data file by global checkpointTs in storage consumer - #4886

Merged
ti-chi-bot[bot] merged 3 commits into
masterfrom
wk989898-patch-4
Apr 23, 2026
Merged

consumer: skip data file by global checkpointTs in storage consumer#4886
ti-chi-bot[bot] merged 3 commits into
masterfrom
wk989898-patch-4

Conversation

@wk989898

@wk989898 wk989898 commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Added functionality to retrieve and update global checkpoint timestamp from metadata file.

What problem does this PR solve?

Issue Number: close #4885

What is changed and how it works?

file discovery is now fenced by the storage metadata checkpoint, instead of discovering every visible schema.json and .index file immediately.

  • Before this patch, getNewFiles() scanned all visible schema/index files
    and immediately inserted them into the consumer’s in-memory seen state
    (tableDMLIdxMap / tableDefMap), then diffDMLMaps() decided what was “new”.
  • That meant a later-version DDL file could be discovered first, executed in
    cmd/storage-consumer/consumer.go:596, and advance tableDDLWatermark. If an
    older-version DML index was only discovered in the next round, it hit the
    unchanged stale-DML branch at cmd/storage-consumer/consumer.go:678 and got
    dropped.
  • After this patch, discovery itself is checkpoint-aware. Files whose
    TableVersion is ahead of the current global checkpoint are skipped before
    they enter the seen maps.
  • That detail matters: skipped files are not marked as seen. So when the
    checkpoint later advances, those files are discovered for the first time
    and diffDMLMaps() still reports them as genuinely new.
  • The stale DDL/DML logic in cmd/storage-consumer/consumer.go:641 and cmd/
    storage-consumer/consumer.go:680 is unchanged. The fix works by preventing
    future schema versions from being discovered too early, so the watermark
    no longer runs ahead of older-version DML discovery.

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

Added functionality to retrieve and update global checkpoint timestamp from metadata file.
@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Apr 22, 2026
@coderabbitai

coderabbitai Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@wk989898 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 50 minutes and 35 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 50 minutes and 35 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: c3e7c9af-6249-4f08-ad2e-28e2b8e08e06

📥 Commits

Reviewing files that changed from the base of the PR and between f195970 and 5103e02.

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

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 the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 22, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

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 a mechanism to filter DML and schema files based on a global checkpoint timestamp retrieved from a 'metadata' file in external storage. The consumer now tracks a globalCheckpointTs and uses it to skip files with a version higher than the current checkpoint. Review feedback identifies a critical backward compatibility issue: if the metadata file is missing, the checkpoint defaults to 0, causing all files to be skipped. It is recommended to only apply the filtering logic when a non-zero checkpoint has been successfully retrieved.

Comment thread cmd/storage-consumer/consumer.go Outdated
Comment thread cmd/storage-consumer/consumer.go Outdated
wk989898 and others added 2 commits April 22, 2026 15:11
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: wk989898 <nhsmwk@gmail.com>
@wk989898

Copy link
Copy Markdown
Collaborator Author

/test storage

1 similar comment
@wk989898

Copy link
Copy Markdown
Collaborator Author

/test storage

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Apr 22, 2026
@ti-chi-bot ti-chi-bot Bot added the lgtm label Apr 22, 2026
@ti-chi-bot

ti-chi-bot Bot commented Apr 22, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3AceShowHand, 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,wlwilliamx]

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 removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 22, 2026
@ti-chi-bot

ti-chi-bot Bot commented Apr 22, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-04-22 09:58:31.547949365 +0000 UTC m=+2159916.753309412: ☑️ agreed by 3AceShowHand.
  • 2026-04-22 10:03:14.93897532 +0000 UTC m=+2160200.144335367: ☑️ agreed by wlwilliamx.

@ti-chi-bot
ti-chi-bot Bot merged commit 1705153 into master Apr 23, 2026
14 checks passed
@ti-chi-bot
ti-chi-bot Bot deleted the wk989898-patch-4 branch April 23, 2026 05:56
@ti-chi-bot

ti-chi-bot Bot commented Apr 23, 2026

Copy link
Copy Markdown

@wk989898: 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-unit-test 5103e02 link unknown /test pull-unit-test

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.

@wk989898 wk989898 added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Aug 10, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm 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/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.

unstable integration test ddl_with_random_move_table

4 participants