Error Occurred When Verifying Table Structure Using sync_diff_inspector

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

Original topic: 使用sync_diff_inspector校验表结构时报错

| username: terry0219

When using sync_diff_inspector to check if the table structures are consistent, an error occurred: “[2023/09/15 16:07:36.843 +08:00] [FATAL] [main.go:129] [“failed to check structure difference”] [error=”[ddl:1629]Comment for field ‘event’ is too long (max = 1024)“] [errorVerbose=”[ddl:1629]Comment for field ‘event’ is too long (max = 1024)\ngithub.com/pingcap/errors.AddStack\n\t/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20221009092201-b66cddb77c32/errors.go:174\ngithub.com/pingcap/errors.(*Error)"

The sync_diff_inspector version is v7.3.0.

| username: Kongdom | Original post link

Is the event field comment too long? This should be a MySQL prompt.

Found from MySQL:

For tables: The table comment can be up to 2048 characters long.
For columns: You can use the COMMENT option to specify a column comment, up to 1024 characters long.
For INDEX: In MySQL 5.6, index definitions can include an optional comment of up to 1024 characters.
For PARTITION: Starting from MySQL 5.6.6, the maximum length of a partition comment is 1024 characters (previously this limit was not clearly defined).
| username: zhanggame1 | Original post link

Check if there is this field and how long the comment is written.

| username: terry0219 | Original post link

It’s MySQL. From this error message, I can’t even see which table it is, so I don’t know which table to check.

| username: Kongdom | Original post link

You can use this to check

SELECT 
    ROW_NUMBER() OVER (order by ORDINAL_POSITION) AS No,
    TABLE_SCHEMA AS DatabaseName, TABLE_NAME AS TableName,
    COLUMN_NAME AS Column, DATA_TYPE AS Type,
    IFNULL(IFNULL(CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION), '') AS Length,
    IFNULL(NUMERIC_SCALE, '') AS DecimalPoint,
    CASE WHEN IS_NULLABLE = 'NO' THEN '√' ELSE '' END AS IsRequired,
    IFNULL(COLUMN_DEFAULT, '') AS DefaultValue,
    CASE WHEN COLUMN_KEY = 'PRI' THEN '√' ELSE '' END AS PrimaryKey,
    IFNULL(COLUMN_COMMENT, '') AS Comment
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME = 'event'
ORDER BY ORDINAL_POSITION;
| username: terry0219 | Original post link

Thank you for the reply. I checked and indeed found that the comment for the event field in one of the tables is very long, exceeding 1024 characters. Is there still a way to validate this situation?

| username: Kongdom | Original post link

Can’t you change the comments?

| username: terry0219 | Original post link

After reviewing the comments, it seems related to business operations, so it’s not appropriate for me to make changes.

| username: Kongdom | Original post link

So can it be ignored?

# (Optional) Ignore the check of certain columns, such as some types that sync-diff-inspector currently does not support (json, bit, blob, etc.)
# Or floating-point type data may have differences in performance between TiDB and MySQL, you can use ignore-columns to ignore the check of these columns
ignore-columns = ["",""]
| username: terry0219 | Original post link

Thank you for the reply. I followed the documentation to configure the ignore settings, but the revalidation still reports the same error.

| username: Kongdom | Original post link

:astonished: Does the same field report an error?

| username: terry0219 | Original post link

Yes, [2023/09/15 17:40:15.552 +08:00] [FATAL] [main.go:129] [“failed to check structure difference”] [error=“[ddl:1629]Comment for field ‘event’ is too long (max = 1024)”] [errorVerbose="[ddl:1629]Comment for field ‘event’ is too long (max = 1024)\ngithub.com/pingcap/errors.AddStack\n\t/go/pkg/mod/github.com/pingcap/errors@v0.11.5-0.20221009092201-b66cddb77c32/errors.go:174\ngithub.com/pingcap/errors.(*Error)

| username: Fly-bird | Original post link

Can the comment be modified if it exceeds 1024?

| username: 大飞哥online | Original post link

So many comments, are you writing an essay? :joy:

| username: Kongdom | Original post link

As mentioned above, it can’t be changed due to business reasons :thinking:

| username: Kongdom | Original post link

That’s strange, I don’t have an environment to reproduce it. You’ll have to try again.

| username: ShawnYan | Original post link

:sweat_smile:
Maybe temporarily clear them, and add them back after verification.