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

dm should consider collation when calculate causality key #9489

Closed
GMHDBJD opened this issue Aug 3, 2023 · 1 comment · Fixed by #9498
Closed

dm should consider collation when calculate causality key #9489

GMHDBJD opened this issue Aug 3, 2023 · 1 comment · Fixed by #9498
Labels
affects-2.0.5 affects-2.0.6 affects-2.0.7 affects-4.0 affects-5.0 affects-5.1 affects-5.2 affects-5.3 affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 area/dm Issues or PRs related to DM. severity/moderate type/bug The issue is confirmed as a bug.

Comments

@GMHDBJD
Copy link
Contributor

GMHDBJD commented 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)
@GMHDBJD GMHDBJD added affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-2.0.5 affects-2.0.6 affects-2.0.7 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 severity/moderate labels Aug 3, 2023
@hihihuhu
Copy link
Contributor

hihihuhu commented Aug 3, 2023

btw, i have tried to convert https://github.com/pingcap/tiflow/blob/v7.1.0/pkg/sqlmodel/causality.go#L113 to lower case, it seems could fix the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-2.0.5 affects-2.0.6 affects-2.0.7 affects-4.0 affects-5.0 affects-5.1 affects-5.2 affects-5.3 affects-5.4 This bug affects the 5.4.x(LTS) versions. affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 area/dm Issues or PRs related to DM. severity/moderate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants