Skip to content

Support retrying ADD PRIMARY KEY #1312

@kennytm

Description

@kennytm

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.

When upstream runs the ADD PRIMARY KEY DDL, and if for some reason it needs to be retried, this currently will cause Drainer to quit due to the unhandled error "Error 1068: Multiple primary key defined".

  1. What did you expect to see?

The error should not crash Drainer, similar to retrying other ADD KEY DDL which its "Error 1061: Duplicate key name `%s`" (ErrDupKeyName) is considered expected and simply ignored.

The error code 1068 (ErrMultiplePriKey) should be added to the IgnoreDDLError function.

tidb-binlog/pkg/sql/sql.go

Lines 156 to 159 in 981fc1d

case infoschema.ErrDatabaseExists.Code(), infoschema.ErrDatabaseNotExists.Code(), infoschema.ErrDatabaseDropExists.Code(),
infoschema.ErrTableExists.Code(), infoschema.ErrTableNotExists.Code(), infoschema.ErrTableDropExists.Code(),
infoschema.ErrColumnExists.Code(), infoschema.ErrColumnNotExists.Code(), infoschema.ErrIndexExists.Code(),
infoschema.ErrKeyNotExists.Code(), dbterror.ErrCantDropFieldOrKey.Code(), tmysql.ErrDupKeyName:

  1. What did you see instead?

N/A

  1. Please provide the relate downstream type and version of drainer.
    (run drainer -V in terminal to get drainer's version)

Originally v5.1.4, but also reproducible up to the latest master.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions