Skip to content

kafka: use default option when meeting authorization and ACLs fails (#5562)#5591

Open
ti-chi-bot wants to merge 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-5562-to-release-nextgen-202603
Open

kafka: use default option when meeting authorization and ACLs fails (#5562)#5591
ti-chi-bot wants to merge 2 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-5562-to-release-nextgen-202603

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #5562

What problem does this PR solve?

Issue Number: close #5563

What is changed and how it works?

If ticdc fails to authorize acl on the kafka server, try using the default option instead of throwing an error when creating the changefeed. The change will fail later.
This is to prevent the changefeed from being created if the user does not grant the relevant acl permissions.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
Kafka Bad config Topic DescribeConfigs granted? changefeed create Post-create result
2.8.0 max.message.bytes=1024 No Success warning, broker rejects large DML with message-too-large
2.8.0 max.message.bytes=1024 Yes Success warning, TiCDC detects ErrMessageTooLarge using adjusted maxMessageBytes=896
3.7.0 max.message.bytes=1024 No Success warning, broker rejects large DML with message-too-large
3.7.0 max.message.bytes=1024 Yes Success warning, TiCDC detects ErrMessageTooLarge using adjusted maxMessageBytes=896
2.8.0 min.insync.replicas=2, RF=1 No Success warning, Kafka send fails after DDL
2.8.0 min.insync.replicas=2, RF=1 Yes Fail at create TiCDC rejects invalid config before creating the changefeed
3.7.0 min.insync.replicas=2, RF=1 No Success normal in this local broker test
3.7.0 min.insync.replicas=2, RF=1 Yes Fail at create TiCDC rejects invalid config before creating the changefeed

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Avoid creating changefeed when meeting authorization and ACL failure

Summary by CodeRabbit

  • Bug Fixes
    • Improved resilience when reading Kafka configuration values.
    • If topic or broker settings can’t be fetched, the app now logs a warning and continues using a safe fallback instead of failing outright.
    • Validation of minimum in-sync replicas is now less likely to block progress when configuration lookup errors occur, while still reporting invalid values.

wk989898 added 2 commits July 6, 2026 10:13
Signed-off-by: wk989898 <nhsmwk@gmail.com>
Signed-off-by: wk989898 <nhsmwk@gmail.com>
@ti-chi-bot ti-chi-bot added 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. type/cherry-pick-for-release-nextgen-202603 labels Jul 6, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kennytm for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 054b4248-f93a-459f-beca-5873cc899571

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ 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.

@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 improves the resilience of Kafka sink option adjustments by falling back to default configurations (such as MaxMessageBytes) or assuming validity when failing to retrieve topic or broker configurations (like max.message.bytes, message.max.bytes, and min.insync.replicas), rather than failing immediately. The review feedback suggests enhancing the warning logs in these fallback paths by including the actual underlying error (zap.Error(err)) to assist operators with troubleshooting.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread pkg/sink/kafka/options.go
Comment on lines 622 to +624
if err != nil {
return errors.Trace(err)
}
topicMaxMessageBytes, err := strconv.Atoi(topicMaxMessageBytesStr)
if err != nil {
return errors.Trace(err)
log.Warn("TiCDC cannot find `max.message.bytes` from topic's configuration, use the option `MaxMessageBytes` as default")
topicMaxMessageBytes = options.MaxMessageBytes

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

When falling back to the default MaxMessageBytes due to an error fetching the topic configuration, it is important to log the actual error err. This helps operators diagnose whether the failure was due to an authorization/ACL issue, a network timeout, or another problem.

Suggested change
if err != nil {
return errors.Trace(err)
}
topicMaxMessageBytes, err := strconv.Atoi(topicMaxMessageBytesStr)
if err != nil {
return errors.Trace(err)
log.Warn("TiCDC cannot find `max.message.bytes` from topic's configuration, use the option `MaxMessageBytes` as default")
topicMaxMessageBytes = options.MaxMessageBytes
if err != nil {
log.Warn("TiCDC cannot find 'max.message.bytes' from topic's configuration, use the option 'MaxMessageBytes' as default", zap.Error(err))
topicMaxMessageBytes = options.MaxMessageBytes

Comment thread pkg/sink/kafka/options.go
Comment on lines 662 to +664
if err != nil {
log.Warn("TiCDC cannot find `message.max.bytes` from broker's configuration")
return errors.Trace(err)
}
brokerMessageMaxBytes, err := strconv.Atoi(brokerMessageMaxBytesStr)
if err != nil {
return errors.Trace(err)
log.Warn("TiCDC cannot find `message.max.bytes` from broker's configuration, use the option `MaxMessageBytes` as default")
brokerMessageMaxBytes = options.MaxMessageBytes

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

When falling back to the default MaxMessageBytes due to an error fetching the broker configuration, the actual error err should be logged to assist with troubleshooting.

Suggested change
if err != nil {
log.Warn("TiCDC cannot find `message.max.bytes` from broker's configuration")
return errors.Trace(err)
}
brokerMessageMaxBytes, err := strconv.Atoi(brokerMessageMaxBytesStr)
if err != nil {
return errors.Trace(err)
log.Warn("TiCDC cannot find `message.max.bytes` from broker's configuration, use the option `MaxMessageBytes` as default")
brokerMessageMaxBytes = options.MaxMessageBytes
if err != nil {
log.Warn("TiCDC cannot find 'message.max.bytes' from broker's configuration, use the option 'MaxMessageBytes' as default", zap.Error(err))
brokerMessageMaxBytes = options.MaxMessageBytes

Comment thread pkg/sink/kafka/options.go
Comment on lines +737 to +738
log.Warn("TiCDC meets error when get `min.insync.replicas` from broker's configuration, assume the config is valid")
return nil

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

When ignoring the error while fetching min.insync.replicas, the actual error err should be logged so that operators can understand why the configuration could not be retrieved.

Suggested change
log.Warn("TiCDC meets error when get `min.insync.replicas` from broker's configuration, assume the config is valid")
return nil
log.Warn("TiCDC meets error when get 'min.insync.replicas' from broker's configuration, assume the config is valid", zap.Error(err))
return nil

@wk989898

wk989898 commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

/test next-gen

@ti-chi-bot

ti-chi-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

@ti-chi-bot: 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-cdc-kafka-integration-heavy-next-gen a172c9b link false /test pull-cdc-kafka-integration-heavy-next-gen

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.

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

Labels

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. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants