Commit 820c4fc
committed
[8.4] PS-9159 : crash due to SELECT GLOBAL_TEMPORARY_TABLES when there is running DDL
https://perconadev.atlassian.net/browse/PS-9159
Problem:
--------
When there are temporary tables created by ALTER, a concurrent
SELECT * FROM information_schema.global_temporary_tables causes a crash.
The temporary table object from ALTER is created using an intermediate name (#sql-ib* or *#P#p0#tmp)
Later I_S query tries to clone the handler object of the temporary table to avoid concurrent
usage of handler object by two threads (THDs). Handler::clone()/ha_innobase::clone() opens the cloned
object again using handler::open()/ha_innobase::open().
This time, it tries to open with the temp table name. The corresponding dd::Table object is valid. So it tries
to load the object from DD and load to cache. A table object with
different name (already exists in cache) but with same table_id. This causes the crash.
Example data from core/rr:
rr) p table->id
$21 = 1075
(rr) p table->name
$22 = {m_name = 0x7f575ec556c0 "test/#sql-3147d6_8#p#p0"}
(rr) p table2->name
$23 = {m_name = 0x7f575428f5d0 "test/b#p#p0#tmp"}
(rr) p table2->id
$24 = 1075
Fix:
----
Since commit 4480f97 (8.0.1), handler::clone()'s behaviour changed. It now assigns the TABLE*
object to handler. This changes the behaviour of the handler::clone(). If TABLE* exists in the handler,
it will do handler::open().
From the I_S query path, we can identify the tables that are never opened in SE from TABLE*->db_stat property. If we have
a temp table, that is not opened in SE, do not try to clone the handler. Actually, handler::clone() is useless for temp tables
from ALTERs anyway. We always return NULL index stats for tmp tables from DDLs (5.7 behaviour) anyway.
(cherry picked from commit bc70691)1 parent eab2f47 commit 820c4fc
File tree
5 files changed
+145
-3
lines changed- mysql-test/suite/percona
- include
- r
- t
- sql
5 files changed
+145
-3
lines changedLines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
Lines changed: 68 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4474 | 4474 | | |
4475 | 4475 | | |
4476 | 4476 | | |
4477 | | - | |
4478 | | - | |
| 4477 | + | |
| 4478 | + | |
| 4479 | + | |
4479 | 4480 | | |
4480 | 4481 | | |
4481 | 4482 | | |
4482 | | - | |
| 4483 | + | |
4483 | 4484 | | |
4484 | 4485 | | |
4485 | 4486 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14075 | 14075 | | |
14076 | 14076 | | |
14077 | 14077 | | |
| 14078 | + | |
| 14079 | + | |
| 14080 | + | |
14078 | 14081 | | |
14079 | 14082 | | |
14080 | 14083 | | |
| |||
0 commit comments