-
Notifications
You must be signed in to change notification settings - Fork 717
ticdc: document Debezium source.start_ts option #23614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,47 @@ The Debezium output format contains the schema information of the current row so | |
|
|
||
| In addition, the original Debezium format does not include important fields such as the unique transaction identifier of the `CommitTS` in TiDB. To ensure data integrity, TiCDC adds two fields, `CommitTs` and `ClusterID`, to the Debezium format to identify the relevant information of TiDB data changes. | ||
|
|
||
| ### Include the transaction start TSO <span class="version-mark">New in v8.5.9</span> | ||
|
|
||
| By default, Debezium JSON DML messages include `source.commit_ts` but not the transaction start TSO. You can optionally include `source.start_ts` (the original PD TSO when the source transaction started) on DML row events only. This option is disabled by default. | ||
|
|
||
| You can enable it in either of the following ways: | ||
|
|
||
| - In `sink-uri`: | ||
|
|
||
| ``` | ||
| kafka://127.0.0.1:9092/topic-name?protocol=debezium&debezium-include-start-ts=true | ||
| ``` | ||
|
|
||
| - In the changefeed configuration file: | ||
|
|
||
| ```toml | ||
| [sink.debezium] | ||
| include-start-ts = true | ||
| ``` | ||
|
|
||
| An explicit URI value takes precedence over the configuration file, including `debezium-include-start-ts=false` overriding `include-start-ts = true`. | ||
|
|
||
| When this option is enabled: | ||
|
|
||
| - DML value messages add integer `source.start_ts` next to `commit_ts`, and the JSON schema declares the field as `int64`. | ||
| - DDL events, WATERMARK/checkpoint events, key messages, and Debezium Avro are unchanged. Setting this option with the Debezium Avro protocol is rejected. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win Use The supplied protocol lists define
As per path instructions: preserve established terminology in Markdown. 📍 Affects 3 files
Source: Path instructions |
||
| - To roll back, disable the option. Messages produced while it is off stay byte-compatible with the previous format. | ||
|
|
||
|
|
||
| > **Note:** | ||
| > | ||
| > `start_ts` is the original uint64 PD TSO, not a millisecond timestamp. Consumers must treat it as a 64-bit integer or a decimal string. Do not parse it as a JavaScript `Number` or IEEE-754 `float64`, which cannot represent an 18-digit TSO exactly. | ||
|
|
||
|
|
||
| When the option is enabled, the `source` block looks like the following: | ||
|
|
||
| ```json | ||
| "source": { | ||
| "commit_ts": 447507027004751877, | ||
| "start_ts": 447507027004751800, | ||
| "cluster_id": "default" | ||
| } | ||
| ``` | ||
|
|
||
| ## Message format definition | ||
|
|
||
| This section describes the message formats of DDL events, DML events and WATERMARK events. | ||
|
|
@@ -572,6 +613,7 @@ The key fields of the preceding JSON data are explained as follows: | |
| | `payload.before` | JSON | The data value before the change event of a statement. For `"c"` events, the value of the `before` field is `null`. | | ||
| | `payload.after` | JSON | The data value after the change event of a statement. For `"d"` events, the value of the `after` field is `null`. | | ||
| | `payload.source.commit_ts` | Number | The `CommitTs` value of the event. | | ||
| | `payload.source.start_ts` | Number | The start TSO of the source transaction. Present only when `debezium-include-start-ts` or `[sink.debezium] include-start-ts` is enabled. Original uint64 PD TSO, not a millisecond timestamp. | | ||
|
|
||
| | `payload.source.db` | String | The name of the database where the event occurs. | | ||
| | `payload.source.table` | String | The name of the table where the event occurs. | | ||
| | `schema.fields` | JSON | The type information of each field in the payload, including the schema information of the row data before and after the change. | | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: pingcap/docs
Length of output: 150
🏁 Script executed:
Repository: pingcap/docs
Length of output: 36589
🏁 Script executed:
Repository: pingcap/docs
Length of output: 22621
🌐 Web query:
pingcap tiflow include-start-ts debezium source.start_ts uint64 int64 implementation💡 Result:
In TiCDC, the start-ts of a changefeed is a Timestamp Oracle (TSO) value [1][2]. When using the Debezium protocol for TiCDC, the protocol output includes metadata fields in the payload, such as payload.source.commit_ts [3]. Regarding your query about include-start-ts, source.start_ts, and type mappings: 1. Start-ts: This is a uint64 value representing the starting TSO in the upstream TiDB cluster [1][4]. When creating or resuming a changefeed, this value is used to specify the point from which TiCDC begins pulling data [5][6]. If not specified (or set to 0), TiCDC fetches a current TSO to start the task [1][2]. 2. Debezium protocol output: TiCDC's Debezium protocol output is designed to be compatible with downstream systems that expect the standard Debezium format, while adding specific fields to ensure data integrity in TiDB [3]. Specifically, TiCDC adds
CommitTsandClusterIDto the payload's source section [3]. The fieldpayload.source.commit_tsis included as a Number type [3]. 3. Data types: TiDB timestamps (TSOs) are 64-bit unsigned integers (uint64) [1][7]. When these values are serialized into JSON for the Debezium protocol, they are typically represented as numbers [3]. Downstream systems or custom consumers reading these JSON messages should handle these as 64-bit integers to prevent precision loss or overflow, as standard JSON numbers are often parsed as 64-bit floating-point numbers in some languages [3]. There is no standard configuration parameter named include-start-ts or source.start_ts in the TiCDC Debezium sink configuration [5][6]. The core parameter for defining the start point is the--start-tsflag used during changefeed creation [5][6]. If you are encountering references to source.start_ts in your integration, it is likely a custom mapping or a reference to the CommitTs field which serves the purpose of identifying the transaction order [3].Citations:
🏁 Script executed:
Repository: pingcap/docs
Length of output: 19063
🌐 Web query:
site:github.com/pingcap/tiflow "debezium-include-start-ts"💡 Result:
There is no configuration parameter named
debezium-include-start-tsorinclude.start.tsin the standard Debezium connector configuration. Based on the technical context of tools like TiCDC (a Change Data Capture tool that supports the Debezium output format), the term "start-ts" refers to a transaction start timestamp, which is a core concept in TiDB-based replication systems (such asignore-txn-start-tsin TiCDC configuration files) [1]. If you are encountering a reference tostart-tsin relation to Debezium, it is likely appearing in one of the following contexts: 1. TiCDC Configuration: When configuring a changefeed to output data in the Debezium protocol, users manage transaction timestamps using settings likeignore-txn-start-tswithin the changefeed's TOML configuration file [1]. 2. Troubleshooting and Logs: System logs for data replication often include thestart-tsof transactions when operations fail or to track progress, but this is not a connector-level "include" flag [2]. If you are looking for ways to include timestamps in Debezium events, Debezium naturally includes source-side timestamps (such assource.ts_msorts_ms) in its standard JSON or Avro message formats, which do not require a specific "include" configuration parameter.Citations:
🏁 Script executed:
Repository: pingcap/docs
Length of output: 36218
🏁 Script executed:
Repository: pingcap/docs
Length of output: 325
🏁 Script executed:
Repository: pingcap/docs
Length of output: 13397
🏁 Script executed:
Repository: pingcap/docs
Length of output: 7689
🌐 Web query:
site:github.com/pingcap/tiflow "source.start_ts" OR "include-start-ts"💡 Result:
The term
source.start_ts(commonly referred to asstart-tsorstartTsin technical contexts, particularly within the TiKV/TiDB/TiCDC ecosystem) refers to the starting timestamp of a data replication stream, task, or transaction filter [1][2][3][4]. In the context of TiCDC (a Change Data Capture tool for TiDB),start-tsdetermines the point in time from which the changefeed begins capturing and replicating data changes [1][5]. Key characteristics include: 1. Function: It acts as a cursor for the replication process [3]. When creating a changefeed, specifying anstart-tsinstructs the system to start processing events from that specific transaction timestamp [1][5]. 2. Validation: To ensure data integrity,start-tsis typically validated against the Garbage Collection (GC) safepoint [1][6]. If astart-tsis older than the GC safepoint, the data has likely been cleaned up, and the changefeed will fail or encounter errors [5][6]. 3. Filtering: In some configurations, transaction filtering is performed based on thestart-ts, allowing users to ignore specific transactions by listing their timestamps [7][4]. While there is no standard global parameter specifically namedsource.start_tswith aninclude-start-tssub-option in general computing, variations of this naming pattern appear in configuration files, CLI flags, and API definitions where timestamps are required to initiate tasks [8][9][3][7]. If you are encounteringinclude-start-tsin a specific piece of software, it likely functions as a boolean flag or configuration property to determine whether the event associated with thestart_tsitself should be included in the processed stream [7].Citations:
🌐 Web query:
TiDB TSO uint64 signed int64 maximum range physical logical bits💡 Result:
In TiDB, the Timestamp Oracle (TSO) provides a 64-bit timestamp that functions as a monotonically increasing identifier [1][2]. While the underlying storage or transport might sometimes involve signed 64-bit integers (int64) in specific programming contexts [3][4], the TSO is conceptually and structurally treated as a 64-bit unsigned integer (uint64) [5][4]. Structure of the 64-bit TSO: - Physical Component: The upper 46 bits represent the physical timestamp, defined as the number of milliseconds elapsed since the Unix epoch (1 January 1970) [1][4]. - Logical Component: The lower 18 bits represent the logical counter [1][2]. This counter allows TiDB to generate up to 2^18 (262,144) unique timestamps within a single millisecond [3][4]. Technical Details: - Bitwise Composition: A TSO is composed by shifting the physical timestamp 18 bits to the left and adding the logical counter: (physical << 18) | logical [5][4]. - Capacity: The 46-bit physical field provides a range of approximately 2,230 years from the Unix epoch, which is sufficient for all practical requirements [4]. The 18-bit logical field ensures that if multiple requests occur within the same millisecond, they can be assigned distinct, ordered timestamps by incrementing the logical counter [1][3]. - Overflow Handling: If the logical counter exceeds its maximum capacity (2^18 - 1), the system waits for the physical clock to advance to the next millisecond to ensure the timestamp remains strictly increasing [3][2]. In practice, developers often use bitwise operations to parse these components—specifically, right-shifting the 64-bit value by 18 bits to extract the physical time and using a bitwise AND mask (0x3FFFF) to extract the logical counter [1][6][4]. Although language-specific implementations (such as in Go or Rust) may use int64 or u64 types, the bitwise structure remains consistent across the architecture [5][3][4].
Citations:
Document the signed
int64range forsource.start_ts.start_tsis documented as auint64TSO, but its schema is documented as signedint64. Anint64schema supports only values from0through9223372036854775807; values above this range can overflow or be rejected. Distinguish the JSON number representation from the schema type, and state the supported range or use a representation that preserves the fulluint64domain.Source: Path instructions