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

"table doesn't exist" error when caller runs CREATE OR REPLACE VIEW concurrently #53673

Closed
lance6716 opened this issue May 30, 2024 · 4 comments · Fixed by #53720
Closed

"table doesn't exist" error when caller runs CREATE OR REPLACE VIEW concurrently #53673

lance6716 opened this issue May 30, 2024 · 4 comments · Fixed by #53720
Assignees
Labels
affects-6.5 affects-7.1 affects-7.5 affects-8.1 component/ddl This issue is related to DDL of TiDB. severity/major type/bug The issue is confirmed as a bug.

Comments

@lance6716
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

found by DM integration tests

2. What did you expect to see? (Required)

3. What did you see instead (Required)

[2024/05/30 11:39:25.566 +08:00] [INFO] [ddl.go:1211] ["start DDL job"] [category=ddl] [job="ID:230, Type:create view, State:queueing, SchemaState:none, SchemaID:121, TableID:229, RowCount:0, ArgLen:3, start time: 2024-05-30 11:39:25.565 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false"] [query="CREATE OR REPLACE VIEW `lightning_task_info`.conflict_view\n\t\t\tAS SELECT 1 AS is_precheck_conflict, task_id, create_time, table_name, NULL AS index_name, NULL AS key_data,\n\t\t\trow_data, NULL AS raw_key, NULL AS raw_value, NULL AS raw_handle, NULL AS raw_row, NULL AS kv_type, path,\n\t\t\toffset, error, row_id FROM `lightning_task_info`.conflict_records;"]
...
[2024/05/30 11:39:25.572 +08:00] [INFO] [ddl.go:1211] ["start DDL job"] [category=ddl] [job="ID:232, Type:create view, State:queueing, SchemaState:none, SchemaID:121, TableID:231, RowCount:0, ArgLen:3, start time: 2024-05-30 11:39:25.571 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false"] [query="CREATE OR REPLACE VIEW `lightning_task_info`.conflict_view\n\t\t\tAS SELECT 1 AS is_precheck_conflict, task_id, create_time, table_name, NULL AS index_name, NULL AS key_data,\n\t\t\trow_data, NULL AS raw_key, NULL AS raw_value, NULL AS raw_handle, NULL AS raw_row, NULL AS kv_type, path,\n\t\t\toffset, error, row_id FROM `lightning_task_info`.conflict_records;"]
...
[2024/05/30 11:39:25.577 +08:00] [INFO] [ddl_worker.go:762] ["finish DDL job"] [worker="worker 3, tp general"] [category=ddl] [jobID=230] [conn=2098198] [job="ID:230, Type:create view, State:synced, SchemaState:public, SchemaID:121, TableID:229, RowCount:0, ArgLen:0, start time: 2024-05-30 11:39:25.565 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, LocalMode: false"]
...
[2024/05/30 11:39:25.584 +08:00] [INFO] [ddl_worker.go:762] ["finish DDL job"] [worker="worker 3, tp general"] [category=ddl] [jobID=232] [conn=2098202] [job="ID:232, Type:create view, State:cancelled, SchemaState:none, SchemaID:121, TableID:231, RowCount:0, ArgLen:3, start time: 2024-05-30 11:39:25.571 +0800 CST, Err:[meta:1146]table doesn't exist, ErrCount:1, SnapshotVersion:0, LocalMode: false"]

4. What is your TiDB version? (Required)

@lance6716 lance6716 added the type/bug The issue is confirmed as a bug. label May 30, 2024
@lance6716
Copy link
Contributor Author

tidb unitsore backend. log
tidb.log

@lance6716
Copy link
Contributor Author

lance6716 commented May 30, 2024

after starting a tiup payground and starting 2 shells to

$ while :; do
mysql -P4000 -h127.0.0.1 -uroot -e "create or replace view test.v as select * from test.t"
done

This problem can be reproduced easily.

ERROR 1146 (42S02) at line 1: table doesn't exist

This will happen for lightning parallel import case because lightning will use CREATE OR REPLACE VIEW

createConflictV1View = `
CREATE OR REPLACE VIEW %s.` + ConflictViewName + `
AS SELECT 0 AS is_precheck_conflict, task_id, create_time, table_name, index_name, key_data, row_data,
raw_key, raw_value, raw_handle, raw_row, kv_type, NULL AS path, NULL AS offset, NULL AS error, NULL AS row_id
FROM %s.` + ConflictErrorTableName + `;
`
createConflictV2View = `
CREATE OR REPLACE VIEW %s.` + ConflictViewName + `
AS SELECT 1 AS is_precheck_conflict, task_id, create_time, table_name, NULL AS index_name, NULL AS key_data,
row_data, NULL AS raw_key, NULL AS raw_value, NULL AS raw_handle, NULL AS raw_row, NULL AS kv_type, path,
offset, error, row_id FROM %s.` + DupRecordTableName + `;
`
createConflictV1V2View = `
CREATE OR REPLACE VIEW %s.` + ConflictViewName + `

@tangenta
Copy link
Contributor

@lance6716 Is it expected to have both tidb-lightning instances success?

@lance6716
Copy link
Contributor Author

@lance6716 Is it expected to have both tidb-lightning instances success?

Yes. lightning assumes CREATE OR REPLACE VIEW like CREATE TABLE IF NOT EXISTS, it should not fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 affects-7.1 affects-7.5 affects-8.1 component/ddl This issue is related to DDL of TiDB. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants