Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

handle schema tracker newer than downstream TiDB #984

Closed
lance6716 opened this issue Sep 3, 2020 · 2 comments · Fixed by #1055
Closed

handle schema tracker newer than downstream TiDB #984

lance6716 opened this issue Sep 3, 2020 · 2 comments · Fixed by #1055
Labels
help wanted This issue wanted some help from contributor severity/moderate type/bug This issue is a bug report

Comments

@lance6716
Copy link
Collaborator

lance6716 commented Sep 3, 2020

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.

update schema tracker in #982 to enjoy more compatibility, some test failed, such as alter FK without schema.

  1. What did you expect to see?

query-status shows nothing

  1. What did you see instead?

query-status shows that error because downstream TiDB doesn't support

  1. Versions of the cluster

@lance6716 lance6716 added help wanted This issue wanted some help from contributor type/bug This issue is a bug report labels Sep 3, 2020
@GMHDBJD GMHDBJD closed this as completed Sep 4, 2020
@lance6716 lance6716 reopened this Sep 4, 2020
@lance6716
Copy link
Collaborator Author

I mean if user execute ALTER ... PK without schema name in upstream, DM's current behaviour can't report error in query-status (at least when I debug that PR someday ago). We still need to support this scenario

@lance6716
Copy link
Collaborator Author

lance6716 commented Sep 7, 2020

use sharding2 case as an example

task

routes:
  sharding-route-rules-table:
    schema-pattern: sharding22
    table-pattern: t1
    target-schema: db_target
    target-table: t_target

  sharding-route-rules-table-2:
    schema-pattern: sharding22
    table-pattern: t2
    target-schema: db_target
    target-table: t_target_2
  sharding-route-rules-table-3:
    schema-pattern: sharding22
    table-pattern: t3
    target-schema: db_target
    target-table: t_target_3

source1, source2

create table sharding22.t2 (id int primary key);
create table sharding22.t3 (id int primary key);
alter table sharding22.t3 add constraint fk foreign key (id) references t2(id);

dmctl no error, but tidb doesn't recieved FK

mysql> SELECT table_name, column_name, constraint_name, referenced_table_name, referenced_column_name FROM information_schema.key_column_usage WHERE table_name IN ('t_target_2', 't_target_3');
+------------+-------------+-----------------+-----------------------+------------------------+
| table_name | column_name | constraint_name | referenced_table_name | referenced_column_name |
+------------+-------------+-----------------+-----------------------+------------------------+
| t_target_2 | id          | PRIMARY         | NULL                  | NULL                   |
| t_target_3 | id          | PRIMARY         | NULL                  | NULL                   |
+------------+-------------+-----------------+-----------------------+------------------------+
2 rows in set (0.00 sec)

while log contains

[2020/09/07 16:21:19.189 +08:00] [ERROR] [baseconn.go:182] ["execute statement failed"] [task=test] [unit="binlog replication"] [query="ALTER TABLE `db_target`.`t_target_3` ADD CONSTRAINT `fk` FOREIGN KEY (`id`) REFERENCES `t2`(`id`)"] [argument="[]"] [error="Error 1046: No database selected"]
[2020/09/07 16:21:19.190 +08:00] [ERROR] [db.go:273] ["execute statements failed after retry"] [task=test] [unit="binlog replication"] [queries="[ALTER TABLE `db_target`.`t_target_3` ADD CONSTRAINT `fk` FOREIGN KEY (`id`) REFERENCES `t2`(`id`)]"] [arguments="[]"] [error="[code=10006:class=database:scope=not-set:level=high], Message: execute statement failed: ALTER TABLE `db_target`.`t_target_3` ADD CONSTRAINT `fk` FOREIGN KEY (`id`) REFERENCES `t2`(`id`), RawCause: Error 1046: No database selected"]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted This issue wanted some help from contributor severity/moderate type/bug This issue is a bug report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants