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

cancelled Import into task is not really cancelled #48736

Closed
aytrack opened this issue Nov 21, 2023 · 1 comment · Fixed by #48928
Closed

cancelled Import into task is not really cancelled #48736

aytrack opened this issue Nov 21, 2023 · 1 comment · Fixed by #48928
Labels
affects-7.5 component/ddl This issue is related to DDL of TiDB. severity/major type/bug This issue is a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Nov 21, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. import into data using local sort for about 5 min
  2. cancel import into task
  3. when the stats show cancelled redo the import into to the same table
  4. check the import result

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

the second import into task will success

3. What did you see instead (Required)

the second import into task failed

-----+--------------------+----------+------------+-----------+------------------+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------+----------------------------+----------------------------+------------+
| Job_ID | Data_Source                                                                                                                                                                                                     | Target_Table       | Table_ID | Phase      | Status    | Source_File_Size | Imported_Rows | Result_Message                                                                                                                                                                   | Create_Time                | Start_Time                 | End_Time                   | Created_By |
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+----------+------------+-----------+------------------+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------+----------------------------+----------------------------+------------+
|      1 | s3://xxx.*.csv?access-key=xxxxxx&endpoint=http%3A%2F%2Fks3-cn-beijing-internal.ksyuncs.com&force-path-style=false&provider=ks&region=Beijing&secret-access-key=xxxxxx | `test`.`xxx` |      102 | importing  | cancelled | 972.5GiB         |          NULL | cancelled by user                                                                                                                                                                | 2023-11-20 23:45:26.123275 | 2023-11-20 23:45:28.678019 | NULL                       | root@%     |
|      2 | s3://xxx.*.csv?access-key=xxxxxx&endpoint=http%3A%2F%2Fks3-cn-beijing-internal.ksyuncs.com&force-path-style=false&provider=ks&region=Beijing&secret-access-key=xxxxxx | `test`.`xxx` |      102 | validating | failed    | 972.5GiB         |          NULL | [Lighting:Restore:ErrChecksumMismatch]checksum mismatched remote vs local => (checksum: 0 vs 10699343643348360583) (total_kvs: 0 vs 4371229747) (total_bytes:0 vs 1519389441133) | 2023-11-20 23:50:52.993131 | 2023-11-20 23:50:55.682565 | 2023-11-21 01:47:38.680702 | root@%     |
+--------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------+----------+------------+-----------+------------------+---------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------+----------------------------+----------------------------+------------+

-- table has been truncated during import into data
MySQL [(none)]> admin show ddl jobs;
+--------+---------+--------------------------+----------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
| JOB_ID | DB_NAME | TABLE_NAME               | JOB_TYPE       | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME         | START_TIME          | END_TIME            | STATE  |
+--------+---------+--------------------------+----------------+--------------+-----------+----------+-----------+---------------------+---------------------+---------------------+--------+
|    105 | test    | xxx                | truncate table | public       |         2 |      102 |         0 | 2023-11-20 23:52:09 | 2023-11-20 23:52:09 | 2023-11-20 23:52:09 | synced |
[2023/11/20 23:52:09.300 +08:00] [INFO] [dispatcher.go:111] ["unregister task success"] [task-id=1]
[2023/11/20 23:52:09.303 +08:00] [INFO] [dispatcher.go:723] [rollback] [type=ImportInto] [task-id=1] [step=import]
[2023/11/20 23:52:09.303 +08:00] [INFO] [dispatcher.go:535] ["execute sql"] [type=ImportInto] [task-id=1] [step=import] [sql="TRUNCATE `test`.`xxx`"] [args=null]
[2023/11/20 23:52:09.303 +08:00] [INFO] [session.go:3916] ["CRUCIAL OPERATION"] [conn=0] [schemaVersion=51] [cur_db=] [sql="TRUNCATE `test`.`item_core`"] [user=]
[2023/11/20 23:52:09.309 +08:00] [INFO] [ddl_worker.go:252] ["add DDL jobs"] [category=ddl] ["batch count"=1] [jobs="ID:105, Type:truncate table, State:queueing, SchemaState:none, SchemaID:2, TableID:102, RowCount:0, ArgLen:3, start time: 2023-11-20 23:52:09.273 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0; "] [table=true]
[2023/11/20 23:52:09.310 +08:00] [INFO] [ddl.go:1082] ["start DDL job"] [category=ddl] [job="ID:105, Type:truncate table, State:queueing, SchemaState:none, SchemaID:2, TableID:102, RowCount:0, ArgLen:3, start time: 2023-11-20 23:52:09.273 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0"] [query="TRUNCATE `test`.`xxx`"]
[2023/11/20 23:52:09.315 +08:00] [INFO] [ddl_worker.go:985] ["run DDL job"] [worker="worker 6, tp general"] [category=ddl] [jobID=105] [category=ddl] [job="ID:105, Type:truncate table, State:queueing, SchemaState:none, SchemaID:2, TableID:102, RowCount:0, ArgLen:0, start time: 2023-11-20 23:52:09.273 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0"]

4. What is your TiDB version? (Required)

v7.5.0

@aytrack aytrack added type/bug This issue is a bug. severity/critical component/ddl This issue is related to DDL of TiDB. affects-7.5 labels Nov 21, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Nov 21, 2023
@aytrack aytrack changed the title cancel cancelled Import into task is not really cancelled Nov 21, 2023
@D3Hunter D3Hunter added severity/major and removed severity/critical may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Nov 21, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Nov 21, 2023
@D3Hunter
Copy link
Contributor

cancel import is an async operation, and during cancel the target table will be truncated, so if next import of same table start immediately, it will import into an old table id, cause validate failed

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

Successfully merging a pull request may close this issue.

2 participants