After changing the field type from int to varchar, the downstream data becomes garbled when synchronized through drainer

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 字段类型由int修改成varchar后,通过drainer同步,在下游为乱码

| username: qhd2004

【TiDB Usage Environment】Production

【TiDB Version】
v5.2.2

【Encountered Problem】
Modified the field type in the upstream using an alter statement, SQL as follows:

alter table table_name MODIFY PRStatus varchar(50) DEFAULT NULL comment 'PR状态'

Query in the upstream:

Query in the downstream:

Modified table structure:

Relevant logs in drainer:

【Attachments】

  • Relevant logs, configuration files, Grafana monitoring (https://metricstool.pingcap.com/)
  • TiUP Cluster Display information
  • TiUP Cluster Edit config information
  • TiDB-Overview monitoring
  • Corresponding module’s Grafana monitoring (if any, such as BR, TiDB-binlog, TiCDC, etc.)
  • Corresponding module logs (including logs from 1 hour before and after the issue)

If the question is related to performance optimization or troubleshooting, please download the script and run it. Please select all and copy-paste the terminal output results for upload.

| username: lichunzhu-PingCAP | Original post link

Will manually executing such DDL downstream result in garbled text?

| username: jiyf | Original post link

The version you are using here is v5.2.2. There was a bug with alter table modify column before this version, which could cause data corruption:

This PR was merged on April 12, 2022. You can check the date of your version:

[bin]$ ./tidb-server -V

If the date is earlier than April 12, then congratulations, you are likely encountering this bug.

The trigger condition for this bug is concurrent execution of alter table modify column. You can check if DDL has been executed repeatedly (concurrently) with the following command:
mysql> admin show ddl jobs;

If it has, then it confirms the issue.

For the trigger conditions of the bug, you can refer to:

| username: qhd2004 | Original post link

Thank you! We were earlier on April 12, 2022.

| username: Hacker_ZcrkjsVg | Original post link

Will upgrading to version 5.4.1 solve this problem?

| username: jiyf | Original post link

In theory, it should be possible!

| username: Christophe | Original post link

Hello, did all previous versions have this issue?

| username: jiyf | Original post link

TiDB versions 5.1, 5.2, and 5.3

| username: Christophe | Original post link

Thank you!
There should also be version 5.0. After we modified it before, the downstream couldn’t synchronize, so we had to clear everything and perform a full synchronization again, then use drainer for incremental synchronization.

| username: system | Original post link

This topic was automatically closed 1 minute after the last reply. No new replies are allowed.