Skip to content

kafka: share one claimcheck instance across encoders (#5718) - #5812

Closed
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-5718-to-release-8.5
Closed

kafka: share one claimcheck instance across encoders (#5718)#5812
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-5718-to-release-8.5

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #5718

What problem does this PR solve?

When Kafka claim-check handling is enabled, every event encoder creates its own ClaimCheck and external storage client. Because an encoder group contains multiple encoders, the number of storage clients grows with encoder concurrency even though they all use the same configuration and storage URI.

Issue Number: close #5719

What is changed and how it works?

  • Create one ClaimCheck at the Kafka sink component level.
  • Inject the same instance into the encoder group and the standalone encoder.
  • Close the underlying claim-check storage when the Kafka sink component is closed.
  • Remove encoder-owned claim-check metric cleanup because ownership now belongs to the Kafka sink component.
  • Update codec and claim-check tests to use the shared instance and verify concurrent writes and storage cleanup.

Pulsar does not enable claim-check handling and continues to pass no ClaimCheck to its encoders.

Check List

Tests

  • Unit test

    go test --tags=intest ./pkg/sink/kafka/claimcheck ./pkg/sink/codec/open ./pkg/sink/codec/canal ./pkg/sink/codec/simple ./downstreamadapter/sink/kafka ./downstreamadapter/sink/pulsar -count=1
    go test -race --tags=intest ./pkg/sink/kafka/claimcheck -count=1
    

Questions

Will it cause performance regression or break compatibility?

It reduces external storage client and connection usage when Kafka claim-check is enabled. It changes exported Go encoder constructor signatures to accept a sink-owned ClaimCheck, but does not change sink configuration, encoded message formats, or runtime protocol compatibility.

Do you need to update user documentation, design documentation or monitoring documentation?

No user-facing documentation or monitoring changes are required because configuration and behavior remain unchanged.

Release note

None

Summary by CodeRabbit

  • New Features

    • Improved handling of oversized Kafka messages through shared claim-check storage across supported encoders.
    • Added safer resource lifecycle management for large-message storage.
  • Bug Fixes

    • Improved concurrent large-message writes and cleanup behavior.
    • Prevented resource leaks when sink or encoder initialization fails.
  • Tests

    • Expanded coverage for concurrent writes, storage closure, and large-message encoding.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Jul 29, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
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

Copy link
Copy Markdown
Member Author

@3AceShowHand This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot

ti-chi-bot Bot commented Jul 29, 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 asddongmen 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

@ti-chi-bot

ti-chi-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

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 ti-community-infra/tichi repository.

@coderabbitai

coderabbitai Bot commented Jul 29, 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 Plus

Run ID: f8a62548-eb08-4c1d-8903-edc1c6a0eecd

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

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.

@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 29, 2026
@3AceShowHand

Copy link
Copy Markdown
Collaborator

close by #5811

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

Labels

do-not-merge/cherry-pick-not-approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants