Skip to content

*: move redo s3 check from cli to server#4281

Merged
ti-chi-bot[bot] merged 13 commits intopingcap:masterfrom
Debra-He:fix/move-redo-s3-check-from-cli-to-server
Mar 6, 2026
Merged

*: move redo s3 check from cli to server#4281
ti-chi-bot[bot] merged 13 commits intopingcap:masterfrom
Debra-He:fix/move-redo-s3-check-from-cli-to-server

Conversation

@Debra-He
Copy link
Contributor

@Debra-He Debra-He commented Feb 26, 2026

What problem does this PR solve?

Issue Number: close #4122

What is changed and how it works?

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

Summary by CodeRabbit

  • New Features

    • Add an option to skip remote/local storage I/O checks during validation.
  • Bug Fixes

    • Changefeed creation no longer fails due to external storage I/O checks while still reporting other config issues.
  • Improvements

    • Redo writer now processes events continuously with improved batching and flush behavior.
  • Tests

    • Added tests covering skip-IO-check behavior and detection of non-IO config errors.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. labels Feb 26, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 26, 2026

Hi @Debra-He. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@ti-chi-bot ti-chi-bot bot added the needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. label Feb 26, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 26, 2026

Welcome @Debra-He!

It looks like this is your first PR to pingcap/ticdc 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to pingcap/ticdc. 😃

@pingcap-cla-assistant
Copy link

pingcap-cla-assistant bot commented Feb 26, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

CLI changefeed creation now disables redo storage I/O checks when completing replica configs; ReplicaConfig/Consistent gained options to toggle redo I/O validation, redo storage validation gained an options-aware entrypoint, tests added, and redo writer batching loop logic was reworked.

Changes

Cohort / File(s) Summary
CLI changefeed create
cmd/cdc/cli/cli_changefeed_create.go
Calls ValidateAndAdjustWithOptions(..., ValidateOptions{EnableRedoIOCheck: false}) so the CLI can skip redo storage I/O checks.
CLI tests
cmd/cdc/cli/cli_changefeed_create_test.go
Adds tests TestCompleteReplicaCfgSkipConsistentStorageIOCheckInCLI and TestCompleteReplicaCfgStillValidateReplicaConfigInCLI to cover skipping IO checks and preserving other validation.
Replica config API
pkg/config/replica_config.go
Introduces ValidateOptions{EnableRedoIOCheck bool}, adds ValidateAndAdjustWithOptions and a delegating ValidateAndAdjust that defaults to IO checks on.
Consistent validation helper
pkg/config/consistent.go
Adds internal validateAndAdjust(enableIOCheck bool) and routes Consistent validation to call redo validation with the provided IO-check flag.
Redo storage validation
pkg/redo/config.go, pkg/redo/config_test.go
Adds StorageValidationOptions{EnableIOCheck bool} and ValidateStorageWithOptions; ValidateStorage delegates to it. Adds test TestValidateStorageWithOptionsSkipIOCheck.
Redo writer loop change
pkg/redo/writer/file/file.go
Reworked encode loop into a continuous for-loop with batching, periodic flushes, cached PostFlush callbacks, and immediate flush when batch size reached.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as "CLI"
    participant Server as "TiCDC Server"
    participant Storage as "External Storage (S3 / FS)"

    CLI->>Server: create changefeed + replica config (EnableRedoIOCheck=false)
    Server->>Storage: validate/init external storage (I/O checks)
    alt storage reachable and valid
        Storage-->>Server: success
        Server-->>CLI: changefeed created (ack)
    else storage unreachable or invalid
        Storage-->>Server: error
        Server-->>CLI: create failed (error)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

lgtm, approved, size/XXL

Suggested reviewers

  • lidezhu
  • bufferflies
  • wk989898

Poem

🐰 I hopped the CLI light-footed, skipping heavy rain,

The servers fetch the bucket while I nibble a grain.
Logs hum like carrots in tidy little rows,
Servers mind the digging where the network wind blows.
🥕 Happy hops — changefeeds grow where the garden knows.

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. The 'What is changed and how it works?' section is empty, and the release note is not filled. Only the issue number is provided. Fill the 'What is changed and how it works?' section with technical details and complete the release note section.
Out of Scope Changes check ⚠️ Warning The changes in pkg/redo/writer/file/file.go include control flow modifications unrelated to moving S3 checks, appearing to be out of scope. Clarify the purpose of the control flow changes in file.go or move them to a separate PR focused on redo writer refactoring.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: moving redo S3 connectivity checks from CLI to server.
Linked Issues check ✅ Passed The PR successfully implements the objective from #4122: moves S3 connectivity validation from CLI to server by introducing validation options and routing checks through server-side validation paths.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@gemini-code-assist
Copy link

Summary of Changes

Hello @Debra-He, 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 refactors the validation process for redo log external storage configurations, moving the check from the client-side command-line interface to the TiCDC server. This change addresses potential issues in deployment environments where the CLI might not have direct network access to external storage services like S3, ensuring that such validations occur in the appropriate server context during changefeed initialization.

Highlights

  • Redo Log S3 Validation Relocation: The responsibility for validating and adjusting redo log external storage configurations (like S3) has been shifted from the cdc cli to the TiCDC server. This change prevents local connectivity checks that could fail in environments where the CLI lacks direct access to the storage.
  • Enhanced Test Coverage: A new unit test was introduced to specifically verify that the CLI's completeReplicaCfg function no longer performs local validation of redo storage, ensuring the intended behavior is maintained.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmd/cdc/cli/cli_changefeed_create.go
    • Removed the ValidateAndAdjust call for replica configuration, specifically for redo external storage, from the CLI's completeReplicaCfg function.
  • cmd/cdc/cli/cli_changefeed_create_test.go
    • Introduced a new test case TestCompleteReplicaCfgDoesNotValidateRedoStorage to confirm that the CLI no longer attempts to validate redo storage locally.
Activity
  • No human activity has occurred on this pull request yet.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 26, 2026
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 moves the redo log S3 connectivity check from the CLI to the TiCDC server. This is achieved by removing the call to ReplicaConfig.ValidateAndAdjust in the CLI's changefeed creation logic. While this correctly prevents the CLI from performing network checks it might not be able to, it also disables all other client-side configuration validations, which could degrade user experience by delaying error feedback. I've added a comment suggesting a more targeted refactoring to address this.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@cmd/cdc/cli/cli_changefeed_create.go`:
- Around line 154-156: The url.Parse error returned from the check on
o.commonChangefeedOptions.sinkURI should be wrapped before returning to preserve
stack context; replace `if _, err :=
url.Parse(o.commonChangefeedOptions.sinkURI); err != nil { return err }` with a
wrapped error using Go error wrapping (e.g. `return fmt.Errorf("invalid sink URI
%q: %w", o.commonChangefeedOptions.sinkURI, err)`), and add the fmt import if
missing so the function (in cli_changefeed_create.go) returns the wrapped error.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5129f10 and a306be8.

📒 Files selected for processing (2)
  • cmd/cdc/cli/cli_changefeed_create.go
  • cmd/cdc/cli/cli_changefeed_create_test.go

@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 3, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 3, 2026

@zier-one: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

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.

@lidezhu
Copy link
Collaborator

lidezhu commented Mar 3, 2026

/test all

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
pkg/redo/writer/file/file.go (1)

316-319: Consider wrapping error for consistency.

Other error returns in this function (lines 313 and 324) use errors.Trace(err), but this one returns the error directly. While write() internally wraps some errors (so double-wrapping should be avoided per guidelines), wrapping here would maintain uniform traceability for any paths in write() that don't wrap.

♻️ Optional fix for consistency
 		err := w.write(e)
 		if err != nil {
-			return err
+			return errors.Trace(err)
 		}

As per coding guidelines, "upstream callers should propagate wrapped errors without wrapping again"—if write() consistently wraps all its errors internally, this change is unnecessary.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/redo/writer/file/file.go` around lines 316 - 319, The return from
w.write(e) is unwrapped but other error returns in this function use
errors.Trace; update the return to return errors.Trace(err) to maintain
consistent error tracing (callers: the call site that does err := w.write(e)
inside the same function), i.e., replace the direct return of err with return
errors.Trace(err) while keeping the existing behavior of write() unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/redo/writer/file/file.go`:
- Around line 321-326: The flushing condition uses `if num >
redo.DefaultFlushBatchSize` which causes an off-by-one (flushes at size+1);
change the check to `if num >= redo.DefaultFlushBatchSize` so `flush()` (and
subsequent `e.PostFlush()`) runs when the batch reaches
`redo.DefaultFlushBatchSize` exactly; update the conditional around `num`,
`flush()`, and `e.PostFlush()` accordingly.

---

Nitpick comments:
In `@pkg/redo/writer/file/file.go`:
- Around line 316-319: The return from w.write(e) is unwrapped but other error
returns in this function use errors.Trace; update the return to return
errors.Trace(err) to maintain consistent error tracing (callers: the call site
that does err := w.write(e) inside the same function), i.e., replace the direct
return of err with return errors.Trace(err) while keeping the existing behavior
of write() unchanged.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eea604a and f036dff.

📒 Files selected for processing (1)
  • pkg/redo/writer/file/file.go

@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 3, 2026

/retest

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 3, 2026

@Debra-He: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/redo/writer/file/file.go`:
- Around line 308-309: In the select branch that handles <-ctx.Done() (where the
code currently returns ctx.Err()), ensure you flush any pending batch work and
run queued cacheEventPostFlush callbacks before returning: call the existing
batch-flush/drain routine (the function that processes the in-flight/write batch
and invokes cacheEventPostFlush callbacks) to drain and execute all pending
callbacks, wait for it to complete or time out appropriately, and only then
return ctx.Err(); update the <-ctx.Done() case to perform that flush/drain step
instead of returning immediately.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f036dff and 4b41482.

📒 Files selected for processing (1)
  • pkg/redo/writer/file/file.go

Comment on lines +308 to +309
case <-ctx.Done():
return ctx.Err()
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Flush pending callbacks before exiting on context cancellation.

Returning immediately on ctx.Done() drops queued cacheEventPostFlush callbacks for already-written events. Please flush pending batch work before exit.

🔧 Proposed fix
-		case <-ctx.Done():
-			return ctx.Err()
+		case <-ctx.Done():
+			if num > 0 {
+				if err := flush(); err != nil {
+					return errors.Trace(err)
+				}
+			}
+			return ctx.Err()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case <-ctx.Done():
return ctx.Err()
case <-ctx.Done():
if num > 0 {
if err := flush(); err != nil {
return errors.Trace(err)
}
}
return ctx.Err()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/redo/writer/file/file.go` around lines 308 - 309, In the select branch
that handles <-ctx.Done() (where the code currently returns ctx.Err()), ensure
you flush any pending batch work and run queued cacheEventPostFlush callbacks
before returning: call the existing batch-flush/drain routine (the function that
processes the in-flight/write batch and invokes cacheEventPostFlush callbacks)
to drain and execute all pending callbacks, wait for it to complete or time out
appropriately, and only then return ctx.Err(); update the <-ctx.Done() case to
perform that flush/drain step instead of returning immediately.

@lidezhu
Copy link
Collaborator

lidezhu commented Mar 3, 2026

/test all

@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 Mar 4, 2026
@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 4, 2026

/retest

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 4, 2026
@wk989898
Copy link
Collaborator

wk989898 commented Mar 4, 2026

Please add a test for the redo file Writer.

@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 4, 2026

/retest

@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 5, 2026

/retest

@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 5, 2026

/retest

@Debra-He Debra-He requested a review from wk989898 March 5, 2026 07:08
@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 5, 2026

/retest

@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 5, 2026

/retest

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 5, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 5, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-03-04 10:06:58.394232403 +0000 UTC m=+352662.972311607: ☑️ agreed by lidezhu.
  • 2026-03-05 08:47:58.857843472 +0000 UTC m=+434323.435922666: ☑️ agreed by wk989898.

@Debra-He Debra-He requested a review from wk989898 March 5, 2026 08:48
@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 5, 2026

/retest

@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 6, 2026

[APPROVALNOTIFIER] This PR is APPROVED

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

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:

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 the approved label Mar 6, 2026
@Debra-He
Copy link
Contributor Author

Debra-He commented Mar 6, 2026

/retest-required

@ti-chi-bot ti-chi-bot bot merged commit 9c02993 into pingcap:master Mar 6, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. lgtm ok-to-test Indicates a PR is ready to be tested. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move S3 connectivity check from cdc cli to cdc server when creating changefeeds with redo log

5 participants