Skip to content

ticdc panic when meet rename tables #4387

@lidezhu

Description

@lidezhu

What did you do?

  1. create a tidb cluster with version v8.1.2;
  2. patch cdc new arch with version v8.5.6-release.1;
  3. create changefeed;
  4. run the following sql in the upstream;
CREATE DATABASE `db_src_x`;
  CREATE DATABASE `db_dst_y`;

  CREATE TABLE `db_src_x`.`tbl_a` (
    `col_id` BIGINT PRIMARY KEY AUTO_INCREMENT,
    `col_name` VARCHAR(64) NOT NULL,
    `col_contact` VARCHAR(128) NOT NULL,
    `col_state` TINYINT NOT NULL DEFAULT 1,
    `col_ctime` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `col_mtime` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
    UNIQUE KEY `uk_col_contact` (`col_contact`),
    KEY `idx_col_name` (`col_name`)
  );

  CREATE TABLE `db_src_x`.`tbl_b` (
    `col_id` BIGINT PRIMARY KEY AUTO_INCREMENT,
    `col_code` VARCHAR(64) NOT NULL,
    `col_ref_id` BIGINT NOT NULL,
    `col_value` DECIMAL(12,2) NOT NULL DEFAULT 0.00,
    `col_flag` VARCHAR(32) NOT NULL DEFAULT 'created',
    `col_ctime` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `col_mtime` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
    UNIQUE KEY `uk_col_code` (`col_code`),
    KEY `idx_col_ref_id` (`col_ref_id`),
    KEY `idx_col_ctime` (`col_ctime`)
  );

  RENAME TABLE
    `db_src_x`.`tbl_b` TO `db_dst_y`.`tbl_b`,
    `db_src_x`.`tbl_a` TO `db_dst_y`.`tbl_a`;

What did you expect to see?

TiCDC works normally

What did you see instead?

TiCDC panic

panic: runtime error: index out of range [0] with length 0

goroutine 2255 [running]:
github.com/pingcap/tidb/pkg/meta/model.GetRenameTablesArgsFromV1(...)
        github.com/pingcap/tidb@v1.1.0-beta.0.20250415080739-a02630cc24cf/pkg/meta/model/job_args.go:873
github.com/pingcap/tidb/pkg/meta/model.(*RenameTablesArgs).decodeV1(0xc0474cf548, 0xc002877a00)
        github.com/pingcap/tidb@v1.1.0-beta.0.20250415080739-a02630cc24cf/pkg/meta/model/job_args.go:852 +0x567
github.com/pingcap/tidb/pkg/meta/model.getOrDecodeArgsV1[...](0xc0474cf548?, 0xc002877a01)
        github.com/pingcap/tidb@v1.1.0-beta.0.20250415080739-a02630cc24cf/pkg/meta/model/job_args.go:66 +0x23
github.com/pingcap/tidb/pkg/meta/model.getOrDecodeArgs[...](0x2f?, 0x6a?)
        github.com/pingcap/tidb@v1.1.0-beta.0.20250415080739-a02630cc24cf/pkg/meta/model/job_args.go:90 +0x25
github.com/pingcap/tidb/pkg/meta/model.GetRenameTablesArgs(...)
        github.com/pingcap/tidb@v1.1.0-beta.0.20250415080739-a02630cc24cf/pkg/meta/model/job_args.go:885
github.com/pingcap/ticdc/logservice/schemastore.buildPersistedDDLEventForRenameTables({_, _, _, _})
        github.com/pingcap/ticdc/logservice/schemastore/persist_storage_ddl_handlers.go:806 +0xbd
github.com/pingcap/ticdc/logservice/schemastore.(*persistentStorage).handleDDLJob(0xc0027c6000, 0xc002877a00)
        github.com/pingcap/ticdc/logservice/schemastore/persist_storage.go:748 +0x1a3
github.com/pingcap/ticdc/logservice/schemastore.(*keyspaceSchemaStore).tryUpdateResolvedTs(0xc04770b2c0)
        github.com/pingcap/ticdc/logservice/schemastore/schema_store.go:150 +0xf85
github.com/pingcap/ticdc/logservice/schemastore.(*schemaStore).RegisterKeyspace.func1(...)
        github.com/pingcap/ticdc/logservice/schemastore/schema_store.go:514
created by github.com/pingcap/ticdc/logservice/schemastore.(*schemaStore).RegisterKeyspace in goroutine 2033
        github.com/pingcap/ticdc/logservice/schemastore/schema_store.go:505 +0x996

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):

(paste TiCDC version here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions