debezium: output start_ts in the source block of DML messages (#5903) - #6039
debezium: output start_ts in the source block of DML messages (#5903)#6039ekexium wants to merge 2 commits into
Conversation
…p#5903) close pingcap#5904 (cherry picked from commit 596decb)
The branch has no ProtocolDebeziumAvro; use canal-json as the non-debezium protocol in the validation test and drop the unused util import.
|
This cherry pick PR is for a release branch and has not yet been approved by triage owners. To merge this cherry pick:
DetailsInstructions 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. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
@ekexium: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in Debezium JSON enhancement (release-8.5 cherry-pick of #5903) to include the transaction start_ts in DML message payload.source, along with schema declaration and decoder support, while keeping backward compatibility via fallback behavior.
Changes:
- Add
debezium-include-start-ts(URI) /[sink.debezium] include-start-ts(config) to control emittingsource.start_tsfor Debezium JSON DML messages. - Update Debezium JSON encoder/schema generation to optionally emit/declare
start_tsfor DML only (DDL/checkpoint unchanged). - Update Debezium decoder to read
source.start_tswhen present and fall back tocommit_tsfor older or invalid messages; add unit tests and API v2 model/config plumbing.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/sink/codec/debezium/decoder.go | Decode source.start_ts with fallback to commit_ts for backward compatibility. |
| pkg/sink/codec/debezium/debezium_test.go | Add encode/schema/round-trip and fallback tests for start_ts. |
| pkg/sink/codec/debezium/codec.go | Conditionally emit and declare start_ts in Debezium JSON DML source block/schema. |
| pkg/sink/codec/debezium/codec_test.go | Assert DDL/checkpoint messages do not declare/contain start_ts. |
| pkg/sink/codec/common/config.go | Add and apply debezium-include-start-ts sink URI/config handling and validation gate. |
| pkg/sink/codec/common/config_test.go | Test URI/config precedence and protocol validation for the new option. |
| pkg/config/sink.go | Add Debezium config field IncludeStartTs and a default constant for output-old-value. |
| pkg/config/replica_config.go | Use the Debezium output-old-value default constant in defaults. |
| api/v2/model.go | Plumb Debezium include_start_ts through API v2 and fix defaulting for output_old_value. |
| api/v2/model_test.go | Add coverage for Debezium config conversion/defaulting including include_start_ts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
[LGTM Timeline notifier]Timeline:
|
|
[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. DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: close #5904
Cherry-pick of #5903 (merge commit 596decb) to release-8.5.
What is changed and how it works?
Add a changefeed-level option (default
false) for Debezium JSON output: the sink URI parameterdebezium-include-start-ts=true, or in the changefeed config:When enabled, Debezium JSON DML value messages carry
source.start_ts(the start TSO of the transaction) next tocommit_ts; the JSON source schema declares the field. DDL/checkpoint messages and key messages are unchanged. The decoder readssource.start_tswhen present and falls back tocommit_tsfor pre-feature or invalid values.Adaptations relative to master (conflict resolution), all due to features that do not exist on release-8.5:
pkg/sink/codec/debezium/avro.go/avro_test.godropped: release-8.5 has no Debezium-Avro codec, so the Avro exclusion changes are not needed here.api/v2/changefeed_toml_test.godropped: TOML output for changefeed query (api/v2: support TOML output for changefeed query via content negotiation #5357) is not on release-8.5; v2DebeziumConfigkeeps json-only tags per branch convention.writeSourceSchemakeeps the release-8.5 signature style (noschemaNameparameter; noEnableTiDBExtensionschema block on this branch) and only adds theincludeStartTsparameter.pkg/sink/codec/common/config.govalidation: only thedebezium-include-start-tsprotocol gate is added; the schema-registry rejection referencingdebezium-avroandconfig.ProtocolDebeziumAvrodo not exist on this branch. The added test usescanal-jsonas the non-debezium protocol.Check List
Tests
pkg/sink/codec/debezium,pkg/sink/codec/common,api/v2,pkg/configall pass on this branch)Questions
Will it cause performance regression or break compatibility?
No. With the default config (option off) output is byte-identical to before. With the option on, the
sourceblock gains one uint64 field and the schema declares it consistently. The decoder falls back tocommit_tswhenstart_tsis absent or invalid.Do you need to update user documentation, design documentation or monitoring documentation?
Yes — same follow-up documentation PR as #5903 (Debezium protocol and changefeed configuration docs).
Release note