dm should consider collation when calculate causality key #9489
Closed
Description
opened on Aug 3, 2023
What did you do?
the table schema is
CREATE TABLE `clusters` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`app` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`rw_host` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`port` int(11) DEFAULT NULL,
`admin_review_required` tinyint(1) DEFAULT NULL,
`is_staging` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */,
UNIQUE KEY `index_clusters_on_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=410226307 /*T![placement] PLACEMENT POLICY=`regular` */
the conflicting changes are
first,
UPDATE `mysql_testing_primary`.`clusters`
WHERE
@1=235023280 /* LONGINT meta=0 nullable=0 is_null=0 */
@2='6cKYK' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@3='aa49k' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@4='1AdQQ7i' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@5=954078180 /* INT meta=0 nullable=1 is_null=0 */
@6=0 /* TINYINT meta=0 nullable=1 is_null=0 */
@7=0 /* TINYINT meta=0 nullable=1 is_null=0 */
SET
@1=235023280 /* LONGINT meta=0 nullable=0 is_null=0 */
@2='UoJ8Io' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@3='300s' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@4='Up4oas' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@5=2030796777 /* INT meta=0 nullable=1 is_null=0 */
@6=0 /* TINYINT meta=0 nullable=1 is_null=0 */
@7=0 /* TINYINT meta=0 nullable=1 is_null=0 */
at 44344809
then,
UPDATE `mysql_testing_primary`.`clusters`
WHERE
@1=234630428 /* LONGINT meta=0 nullable=0 is_null=0 */
@2='v7uTIn' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@3='2gPeNU' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@4='COzQ' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@5=712827593 /* INT meta=0 nullable=1 is_null=0 */
@6=0 /* TINYINT meta=0 nullable=1 is_null=0 */
@7=1 /* TINYINT meta=0 nullable=1 is_null=0 */
SET
@1=234630428 /* LONGINT meta=0 nullable=0 is_null=0 */
@2='6ckYK' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@3='KHEtq118P' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@4='g9oU' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
@5=166786945 /* INT meta=0 nullable=1 is_null=0 */
@6=0 /* TINYINT meta=0 nullable=1 is_null=0 */
@7=1 /* TINYINT meta=0 nullable=1 is_null=0 */
at 44495569
What did you expect to see?
dm replicate rows by order
What did you see instead?
dm replicate the second change before the first one and get duplicate key error
the 3rd byte difference between 6ckYK
and 6cKYK
in the example, it seems it is just a simple equal test https://github.com/pingcap/tiflow/blob/v7.1.0/dm/syncer/causality.go#L137
Versions of the cluster
DM version (run dmctl -V
or dm-worker -V
or dm-master -V
):
(paste DM version here, and you must ensure versions of dmctl, DM-worker and DM-master are same)
Upstream MySQL/MariaDB server version:
(paste upstream MySQL/MariaDB server version here)
Downstream TiDB cluster version (execute SELECT tidb_version();
in a MySQL client):
(paste TiDB cluster version here)
How did you deploy DM: tiup or manually?
(leave TiUP or manually here)
Other interesting information (system version, hardware config, etc):
>
>
current status of DM cluster (execute query-status <task-name>
in dmctl)
(paste current status of DM cluster here)
Activity