[MDEV-19449] 1030: Got error 168 "Unknown (generic) error from engine" for valid TRUNCATE (temporary) TABLE Created: 2019-05-13 Updated: 2019-05-14 Resolved: 2019-05-14 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Temporary, Storage Engine - InnoDB |
| Affects Version/s: | 10.2.24 |
| Fix Version/s: | 10.2.25 |
| Type: | Bug | Priority: | Major |
| Reporter: | Matthias Leich | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | affects-tests-10.2 | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
|
| Comments |
| Comment by Anel Husakovic [ 2019-05-13 ] | ||||||||||||||||||
|
It seems like table is "locked".
| ||||||||||||||||||
| Comment by Matthias Leich [ 2019-05-13 ] | ||||||||||||||||||
|
| ||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-05-13 ] | ||||||||||||||||||
|
Note: TEMPORARY TABLE never uses native ALTER TABLE, always ALGORITHM=COPY. I suspect that something in ALTER TABLE is corrupting the handler::table_share so that TRUNCATE in InnoDB fails (and preserves the old contents of the table). | ||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-05-13 ] | ||||||||||||||||||
|
I missed the following message:
The ml_19.test
Also, the test failed to reproduce the problem with 10.3 for me. In any case, the TRUNCATE of TEMPORARY TABLE should avoid renaming the table. It should suffice to simply drop and create the table. | ||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-05-14 ] | ||||||||||||||||||
|
I did some more debugging. I am afraid that the problem could be unique to the 10.2 series. If I remember correctly, MariaDB 10.3 allows multiple concurrent handles to temporary tables, but 10.2 is not supposed to allow that. The problem appears to be that at the time the TRUNCATE executes, there will be multiple open table handles to the temporary table.
The problem occurs when a table is renamed from the same name (#sql-ib19 in my case) to the same name. That should not be possible, but apparently an extraneous table handle for the temporary table is still referring to the temporary table before the first TRUNCATE TABLE operation. Because of the background drop queue, that table was not dropped yet, and also AddressSanitizer does not notice any foul play. Here is a slightly edited and commented version of ml_19.test
| ||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-05-14 ] | ||||||||||||||||||
|
Backporting (cherry-picking) the | ||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-05-14 ] | ||||||||||||||||||
|
I tried the test case on 10.3 with the
|