Skip to content
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

TiCDC sql event filter can not handle ddl that using "" as identifier. #9876

Closed
asddongmen opened this issue Oct 13, 2023 · 1 comment · Fixed by #9941
Closed

TiCDC sql event filter can not handle ddl that using "" as identifier. #9876

asddongmen opened this issue Oct 13, 2023 · 1 comment · Fixed by #9941
Assignees
Labels
affects-6.5 affects-7.1 affects-7.5 area/ticdc Issues or PRs related to TiCDC. severity/moderate This is a moderate bug. type/bug This is a bug.

Comments

@asddongmen
Copy link
Contributor

asddongmen commented Oct 13, 2023

What did you do?

  1. create a changefeed
  2. add ANSI_QUOTES to upstream TiDB SQL mode variables.
set sql_mode= "ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, NO_ZERO_IN_DATE, NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION, ANSI_QUOTES"
  1. create a table in upstream TiDB using a ddl that the its table name and column name are quoted by "".
CREATE TABLE "my_table" (
  "column1" VARCHAR(40) NOT NULL,
  "column2" DECIMAL(1,0) NOT NULL,
  "column3" DECIMAL(5,0) NOT NULL DEFAULT '0',
  "column4" CHAR(9) NOT NULL,
  "column5" VARCHAR(32) NOT NULL,
  "column6" DECIMAL(1,0) NOT NULL,
  "column7" DECIMAL(1,0) DEFAULT NULL,
  "column8" DECIMAL(13,0) DEFAULT NULL,
  "column9" DECIMAL(13,0) DEFAULT NULL,
  "column10" DECIMAL(3,0) DEFAULT NULL,
  "column11" DATETIME(6) DEFAULT NULL,
  "column12" DECIMAL(1,0) NOT NULL,
  "column13" CHAR(8) DEFAULT NULL,
  "column14" DATETIME(6) DEFAULT NULL,
  "column15" CHAR(8) DEFAULT NULL,
  "column16" DECIMAL(13,0) DEFAULT NULL,
  "column17" DECIMAL(13,0) DEFAULT NULL,
  "column18" DECIMAL(13,0) DEFAULT NULL,
  "column19" DECIMAL(13,0) DEFAULT NULL,
  "column20" DECIMAL(13,0) DEFAULT NULL,
  "column21" DATETIME(6) DEFAULT NULL,
  "column22" VARCHAR(30) DEFAULT NULL,
  "column23" DECIMAL(13,0) DEFAULT NULL,
  "column24" CHAR(20) DEFAULT NULL,
  "column25" VARCHAR(30) DEFAULT NULL,
  "column26" DECIMAL(13,0) DEFAULT NULL,
  "column27" CHAR(20) DEFAULT NULL,
  "column28" DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  "column29" DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (column1, column2, column3),
  KEY idx_column4_search_key (column5),
  KEY idx_column11_search_key (column11)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

What did you expect to see?

changefeed works normally.

What did you see instead?

Changefeed error.

> ./cdc cli changefeed list
[
  {
    "id": "test1",
    "namespace": "default",
    "summary": {
      "state": "warning",
      "tso": 444904478024925188,
      "checkpoint": "2023-10-13 13:44:55.786",
      "error": {
        "time": "2023-10-13T13:44:57.87892+08:00",
        "addr": "127.0.0.1:8300",
        "code": "CDC:ErrHandleDDLFailed",
        "message": "[CDC:ErrHandleDDLFailed]handle ddl failed, job: ID:108, Type:create table, State:done, SchemaState:public, SchemaID:2, TableID:107, RowCount:0, ArgLen:0, start time: 2023-10-13 13:44:56.336 +0800 CST, Err:\u003cnil\u003e, ErrCount:0, SnapshotVersion:0, query: CREATE TABLE \"my_table\" (\n  \"column1\" VARCHAR(40) NOT NULL,\n  \"column2\" DECIMAL(1,0) NOT NULL,\n  \"column3\" DECIMAL(5,0) NOT NULL DEFAULT '0',\n  \"column4\" CHAR(9) NOT NULL,\n  \"column5\" VARCHAR(32) NOT NULL,\n  \"column6\" DECIMAL(1,0) NOT NULL,\n  \"column7\" DECIMAL(1,0) DEFAULT NULL,\n  \"column8\" DECIMAL(13,0) DEFAULT NULL,\n  \"column9\" DECIMAL(13,0) DEFAULT NULL,\n  \"column10\" DECIMAL(3,0) DEFAULT NULL,\n  \"column11\" DATETIME(6) DEFAULT NULL,\n  \"column12\" DECIMAL(1,0) NOT NULL,\n  \"column13\" CHAR(8) DEFAULT NULL,\n  \"column14\" DATETIME(6) DEFAULT NULL,\n  \"column15\" CHAR(8) DEFAULT NULL,\n  \"column16\" DECIMAL(13,0) DEFAULT NULL,\n  \"column17\" DECIMAL(13,0) DEFAULT NULL,\n  \"column18\" DECIMAL(13,0) DEFAULT NULL,\n  \"column19\" DECIMAL(13,0) DEFAULT NULL,\n  \"column20\" DECIMAL(13,0) DEFAULT NULL,\n  \"column21\" DATETIME(6) DEFAULT NULL,\n  \"column22\" VARCHAR(30) DEFAULT NULL,\n  \"column23\" DECIMAL(13,0) DEFAULT NULL,\n  \"column24\" CHAR(20) DEFAULT NULL,\n  \"column25\" VARCHAR(30) DEFAULT NULL,\n  \"column26\" DECIMAL(13,0) DEFAULT NULL,\n  \"column27\" CHAR(20) DEFAULT NULL,\n  \"column28\" DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),\n  \"column29\" DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),\n  PRIMARY KEY (column1, column2, column3),\n  KEY idx_column4_search_key (column5),\n  KEY idx_column11_search_key (column11)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin, startTs: 444904478169104400. If you want to skip this DDL and continue with replication, you can manually execute this DDL downstream. Afterwards, add `ignore-txn-start-ts=[444904478169104400]` to the changefeed in the filter configuration.: [CDC:ErrConvertDDLToEventTypeFailed]failed to convert ddl 'CREATE TABLE \"my_table\" (\n  \"column1\" VARCHAR(40) NOT NULL,\n  \"column2\" DECIMAL(1,0) NOT NULL,\n  \"column3\" DECIMAL(5,0) NOT NULL DEFAULT '0',\n  \"column4\" CHAR(9) NOT NULL,\n  \"column5\" VARCHAR(32) NOT NULL,\n  \"column6\" DECIMAL(1,0) NOT NULL,\n  \"column7\" DECIMAL(1,0) DEFAULT NULL,\n  \"column8\" DECIMAL(13,0) DEFAULT NULL,\n  \"column9\" DECIMAL(13,0) DEFAULT NULL,\n  \"column10\" DECIMAL(3,0) DEFAULT NULL,\n  \"column11\" DATETIME(6) DEFAULT NULL,\n  \"column12\" DECIMAL(1,0) NOT NULL,\n  \"column13\" CHAR(8) DEFAULT NULL,\n  \"column14\" DATETIME(6) DEFAULT NULL,\n  \"column15\" CHAR(8) DEFAULT NULL,\n  \"column16\" DECIMAL(13,0) DEFAULT NULL,\n  \"column17\" DECIMAL(13,0) DEFAULT NULL,\n  \"column18\" DECIMAL(13,0) DEFAULT NULL,\n  \"column19\" DECIMAL(13,0) DEFAULT NULL,\n  \"column20\" DECIMAL(13,0) DEFAULT NULL,\n  \"column21\" DATETIME(6) DEFAULT NULL,\n  \"column22\" VARCHAR(30) DEFAULT NULL,\n  \"column23\" DECIMAL(13,0) DEFAULT NULL,\n  \"column24\" CHAR(20) DEFAULT NULL,\n  \"column25\" VARCHAR(30) DEFAULT NULL,\n  \"column26\" DECIMAL(13,0) DEFAULT NULL,\n  \"column27\" CHAR(20) DEFAULT NULL,\n  \"column28\" DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),\n  \"column29\" DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),\n  PRIMARY KEY (column1, column2, column3),\n  KEY idx_column4_search_key (column5),\n  KEY idx_column11_search_key (column11)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin' to filter event type: line 1 column 23 near \"\"my_table\" (\n  \"column1\" VARCHAR(40) NOT NULL,\n  \"column2\" DECIMAL(1,0) NOT NULL,\n  \"column3\" DECIMAL(5,0) NOT NULL DEFAULT '0',\n  \"column4\" CHAR(9) NOT NULL,\n  \"column5\" VARCHAR(32) NOT NULL,\n  \"column6\" DECIMAL(1,0) NOT NULL,\n  \"column7\" DECIMAL(1,0) DEFAULT NULL,\n  \"column8\" DECIMAL(13,0) DEFAULT NULL,\n  \"column9\" DECIMAL(13,0) DEFAULT NULL,\n  \"column10\" DECIMAL(3,0) DEFAULT NULL,\n  \"column11\" DATETIME(6) DEFAULT NULL,\n  \"column12\" DECIMAL(1,0) NOT NULL,\n  \"column13\" CHAR(8) DEFAULT NULL,\n  \"column14\" DATETIME(6) DEFAULT NULL,\n  \"column15\" CHAR(8) DEFAULT NULL,\n  \"column16\" DECIMAL(13,0) DEFAULT NULL,\n  \"column17\" DECIMAL(13,0) DEFAULT NULL,\n  \"column18\" DECIMAL(13,0) DEFAULT NULL,\n  \"column19\" DECIMAL(13,0) DEFAULT NULL,\n  \"column20\" DECIMAL(13,0) DEFAULT NULL,\n  \"column21\" DATETIME(6) DEFAULT NULL,\n  \"column22\" VARCHAR(30) DEFAULT NULL,\n  \"column23\" DECIMAL(13,0) DEFAULT NULL,\n  \"column24\" CHAR(20) DEFAULT NULL,\n  \"column25\" VARCHAR(30) DEFAULT NULL,\n  \"column26\" DECIMAL(13,0) DEFAULT NULL,\n  \"column27\" CHAR(20) DEFAULT NULL,\n  \"column28\" DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),\n  \"column29\" DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),\n  PRIMARY KEY (column1, column2, column3),\n  KEY idx_column4_search_key (column5),\n  KEY idx_column11_search_key (column11)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin\" "
      }
    }
  }
]

Versions of the cluster

Upstream TiDB cluster version (execute SELECT tidb_version(); in a MySQL client):

(paste TiDB cluster version here)

Upstream TiKV version (execute tikv-server --version):

(paste TiKV version here)

TiCDC version (execute cdc version):

v7.1.1
@asddongmen asddongmen added type/bug This is a bug. area/ticdc Issues or PRs related to TiCDC. labels Oct 13, 2023
@github-actions github-actions bot added this to Need Triage in Question and Bug Reports Oct 13, 2023
@asddongmen asddongmen self-assigned this Oct 13, 2023
@asddongmen
Copy link
Contributor Author

The reason for this issue is that the internal parser used by TiCDC uses the default SQL mode, while the upstream TiDB has added the "an" SQL mode. As a result, TiCDC's parser cannot correctly interpret double quotes (""), treating them as identifiers.

@asddongmen asddongmen changed the title TiCDC sql event filter can not handle some sql correctly. TiCDC sql event filter can not handle ddl that using "" as identifier. Oct 13, 2023
@asddongmen asddongmen added needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. affects-7.5 and removed needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. labels Nov 1, 2023
@ti-chi-bot ti-chi-bot bot closed this as completed in #9941 Nov 2, 2023
Question and Bug Reports automation moved this from Need Triage to Done Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 affects-7.1 affects-7.5 area/ticdc Issues or PRs related to TiCDC. severity/moderate This is a moderate bug. type/bug This is a bug.
Development

Successfully merging a pull request may close this issue.

1 participant