Skip to content

Commit 47ab4fe

Browse files
TomShawnsre-bot
authored andcommitted
cherry pick pingcap#2751 to release-4.0
Signed-off-by: sre-bot <sre-bot@pingcap.com>
1 parent 4cb3272 commit 47ab4fe

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

TOC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
+ [Statement Summary Tables](/statement-summary-tables.md)
8383
+ [Troubleshoot Cluster Setup](/troubleshoot-tidb-cluster.md)
8484
+ [TiDB Troubleshooting Map](/tidb-troubleshooting-map.md)
85+
+ [Handle TiCDC Issues](/ticdc/troubleshoot-ticdc.md)
8586
+ [Troubleshoot TiFlash](/tiflash/troubleshoot-tiflash.md)
8687
+ Performance Tuning
8788
+ Software Tuning

ticdc/ticdc-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ aliases: ['/docs/stable/reference/tools/ticdc/overview/']
88
# TiCDC Overview
99

1010
> **Note:**
11-
>
11+
>
1212
> TiCDC is experimental. It is **not recommended** to use this feature in the production environment.
1313
1414
[TiCDC](https://github.com/pingcap/ticdc) is a tool for replicating the incremental data of TiDB. This tool is implemented by pulling TiKV change logs. It can restore data to a consistent state with any upstream TSO, and provides [TiCDC Open Protocol](/ticdc/ticdc-open-protocol.md) to support other systems to subscribe to data changes.

ticdc/troubleshoot-ticdc.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Handle TiCDC Issues
3+
summary: Learn how to handle TiCDC issues.
4+
category: reference
5+
---
6+
7+
# Handle TiCDC Issues
8+
9+
This document introduces the common issues and errors that you might encounter when using TiCDC, and the corresponding maintenance and troubleshooting methods.
10+
11+
## How to choose `start-ts` when starting a task
12+
13+
The `start-ts` of a replication task corresponds to a Timestamp Oracle (TSO) in the upstream TiDB cluster. TiCDC requests data from this TSO in a replication task. Therefore, the `start-ts` of the replication task must meet the following requirements:
14+
15+
- The value of `start-ts` is larger than the `tikv_gc_safe_point` value of the current TiDB cluster. Otherwise, an error occurs when you create a task.
16+
- Before starting a task, ensure that the downstream has all data before `start-ts`. For scenarios such as replicating data to message queues, if the data consistency between upstream and downstream is not required, you can relax this requirement according to your application need.
17+
18+
If you do not specify `start-ts`, or specify `start-ts` as `0`, when a replication task is started, TiCDC gets a current TSO and starts the task from this TSO.
19+
20+
## Some tables cannot be replicated when you start a task
21+
22+
When you execute `cdc cli changefeed create` to create a replication task, TiCDC checks whether the upstream tables meet the [replication restrictions](/ticdc/ticdc-overview.md#restrictions). If some tables do not meet the restrictions, `some tables are not eligible to replicate` is returned with a list of ineligible tables. You can choose `Y` or `y` to continue creating the task, and all updates on these tables are automatically ignored during the replication. If you choose an input other than `Y` or `y`, the replication task is not created.
23+
24+
## How to handle replication interruption
25+
26+
A replication task might be interrupted in the following known scenarios:
27+
28+
- The downstream continues to be abnormal, and TiCDC still fails after many retries.
29+
30+
- In this scenario, TiCDC saves the task information. Because TiCDC has set the service GC safepoint in PD, the data after the task checkpoint is not cleaned by TiKV GC within the valid period of `gc-ttl`.
31+
- Handling method: You can resume the replication task via the HTTP interface after the downstream is back to normal.
32+
33+
- Replication cannot continue because of incompatible SQL statement(s) in the downstream.
34+
35+
- In this scenario, TiCDC saves the task information. Because TiCDC has set the service GC safepoint in PD, the data after the task checkpoint is not cleaned by TiKV GC within the valid period of `gc-ttl`.
36+
- Handling procedures:
37+
1. Query the status information of the replication task using the `cdc cli changefeed query` command and record the value of `checkpoint-ts`.
38+
2. Use the new task configuration file and add the `ignore-txn-commit-ts` parameter to skip the transaction corresponding to the specified `commit-ts`.
39+
3. Stop the old replication task via HTTP API. Execute `cdc cli changefeed create` to create a new task and specify the new task configuration file. Specify `checkpoint-ts` recorded in step 1 as the `start-ts` and start a new task to resume the replication.
40+
41+
## `gc-ttl` and file sorting
42+
43+
Since v4.0.0-rc.1, PD supports external services in setting the service-level GC safepoint. Any service can register and update its GC safepoint. PD ensures that the key-value data smaller than this GC safepoint is not cleaned by GC. Enabling this feature in TiCDC ensures that the data to be consumed by TiCDC is retained in TiKV without being cleaned by GC when the replication task is unavailable or interrupted.
44+
45+
When starting the TiCDC server, you can specify the Time To Live (TTL) duration of GC safepoint through `gc-ttl`, which means the longest time that data is retained within the GC safepoint. This value is set by TiCDC in PD, which is 86,400 seconds by default.
46+
47+
If the replication task is interrupted for a long time and a large volume of unconsumed data is accumulated, Out of Memory (OOM) might occur when TiCDC is started. In this situation, you can enable the file sorting feature of TiCDC that uses system files for sorting. To enable this feature, pass `--sort-engine=file` and `--sort-dir=/path/to/sort_dir` to the `cdc cli` command when creating a replication task. For example:
48+
49+
{{< copyable "shell-regular" >}}
50+
51+
```shell
52+
cdc cli changefeed create --pd=http://10.0.10.25:2379 --start-ts=415238226621235200 --sink-uri="mysql://root:123456@127.0.0.1:3306/" --sort-engine="file" --sort-dir="/data/cdc/sort"
53+
```
54+
55+
> **Note:**
56+
>
57+
> TiCDC (the 4.0 version) does not support dynamically modifying the file sorting and memory sorting yet.

0 commit comments

Comments
 (0)