Skip to content

sink: add debezium-avro protocol (#5475) - #6940

Closed
ti-chi-bot wants to merge 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-5475-to-release-8.5
Closed

ti-chi-bot wants to merge 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-5475-to-release-8.5

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #5475

What problem does this PR solve?

Issue Number: close #5476

What is changed and how it works?

This PR introduces a new Kafka sink protocol: protocol=debezium-avro.

The new protocol is intended for users who need both:

  1. Debezium-compatible change event semantics.
  2. Confluent Avro binary encoding with Schema Registry integration.

Before this change, TiCDC had two separate protocols that each solved only
one side of the requirement:

  • protocol=debezium emits Debezium-style key/value messages, but the
    messages are JSON and the schema is embedded in each message.
  • protocol=avro emits Confluent Avro messages and registers schemas in
    Schema Registry, but the payload is TiCDC's flat row format rather than a
    Debezium Envelope.

protocol=debezium-avro combines these two capabilities. It reuses the
Debezium codec's event model and field extraction logic, and reuses the
existing Avro Schema Registry registration and Confluent wire-format flow.

Users can enable it with a sink URI like:

 cdc cli changefeed create \
  --server=http://127.0.0.1:8300 \
  --changefeed-id=debezium-avro-demo \
  --sink-uri='kafka://127.0.0.1:9092/ticdc-debezium-avro-glue-demo' \
  --config=/path/to/changefeed-glue.toml

Protocol and configuration

This PR adds ProtocolDebeziumAvro to the sink protocol enum and protocol
parser, so protocol=debezium-avro can be used in Kafka sink URIs and
changefeed configs.

The protocol is treated as an Avro-like protocol where needed, including:

  • requiring Schema Registry configuration;
  • preserving Schema Registry fields in changefeed config cleanup;
  • using Kafka Avro-related validation paths;
  • creating the Debezium Avro encoder/decoder from the codec builder;
  • supporting the bundled cdc_kafka_consumer decode path.

For the MVP, Debezium Avro supports Confluent Schema Registry through
schema-registry and AWS Glue Schema Registry.

The protocol also keeps the existing Avro type-mode options where
applicable:

  • avro-decimal-handling-mode
  • avro-bigint-unsigned-handling-mode

Check List

Tests

  • Unit test
  • Integration test

Questions

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

Release note

support debezium-avro protocol

Summary by CodeRabbit

  • Bug Fixes
    • Kafka changefeed handling now varies by protocol and table type when processing fallback row events. Depending on the configuration, these events are appended or ignored.
    • Debezium Avro encoding now uses shared schema management, and Avro decoding returns decoded row events directly.
  • Changes
    • Debezium JSON output no longer applies the binary, unsigned BIGINT, and decimal handling modes used by Avro. The JSON start_ts field remains controlled by its configuration.

Signed-off-by: ti-chi-bot <ci@pingcap.com>
@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 Denotes a PR that will be considered when it comes time to generate release notes. 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. labels Nov 19, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 19, 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

@wk989898 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 Nov 19, 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.

@ti-chi-bot ti-chi-bot Bot removed the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The diff changes Kafka sink setup and fallback-row handling, and updates Debezium Avro encoding and decoding. It also contains unresolved merge-conflict markers in several Go files and the integration script, leaving some supplied source content syntactically invalid.

Changes: Debezium Avro and Kafka sink

Layer / File(s) Summary
Kafka component setup
downstreamadapter/sink/kafka/helper.go
Adds Kafka option, factory, router, selector, encoder, admin-client, and topic-manager setup. Errors return the partially initialized component; an admin client is closed on initialization failure. The added code contains merge-conflict markers.
Kafka routing and fallback rows
api/v2/changefeed.go, cmd/kafka-consumer/consumer.go, cmd/kafka-consumer/writer.go, cmd/kafka-consumer/writer_test.go
Changes fallback-DML handling based on protocol, table type, and enableTableAcrossNodes. The router calls, metadata check, and test changes contain unresolved conflict markers.
Debezium Avro encoder and schema handling
pkg/sink/codec/builder.go, pkg/sink/codec/common/config.go, pkg/sink/codec/common/config_test.go, pkg/sink/codec/debezium/encoder.go, pkg/sink/codec/debezium/avro.go, pkg/sink/codec/debezium/codec.go
Changes encoder schema-manager setup and schema lookup. Several encoding-mode branches now apply only to Avro, and source-schema generation no longer takes an includeStartTs argument. The shown configuration checks retain their existing behavior. The builder, encoder, and configuration test contain conflict markers.
Debezium Avro decoding and validation
pkg/sink/codec/debezium/avro_decoder.go, pkg/sink/codec/debezium/avro_test.go, tests/integration_tests/debezium_avro/run.sh
Replaces the decoder’s LRU schema cache with a mutex-protected map and changes its accessor to return DML events. Tests use the updated encoder and decoder APIs. The integration script contains conflict markers.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Suggested reviewers: wk989898, 3aceshowhand, lidezhu

Merge Risk: Critical · up to 22de7

This cherry-pick still contains unresolved merge conflicts across sink, codec, consumer, config tests and the integration script, so the release branch cannot build. Several incoming alternatives would also change existing Debezium JSON output and consumer behavior. The conflicts must be resolved consistently before this can merge.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the schema rows,
Then hops where Avro bytes now flow.
A mutex guards each cached key,
While tables sort—or skip—to see.
The rabbit leaves a carrot by the code.

@ti-chi-bot ti-chi-bot Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 19, 2026
PR pingcap#5809 already backported pingcap#5475 to release-8.5. The second automated cherry-pick only added unresolved conflict blocks. Restore the release branch content to retain the backport and its follow-up changes.
@ti-chi-bot

ti-chi-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wk989898

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

Copy link
Copy Markdown
Member Author

Cherry-pick conflicts appear resolved; removing the do-not-merge/hold label.

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 19, 2026
@ti-chi-bot ti-chi-bot Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 19, 2026
@wk989898 wk989898 closed this Nov 19, 2026
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 lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 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