[MDEV-22934] Table disappear after two alter table command Created: 2020-06-18 Updated: 2023-11-27 Resolved: 2020-08-18 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 10.1, 10.3.23, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.1.48, 10.2.35, 10.3.26, 10.4.16, 10.5.7 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Lay András | Assignee: | Thirunarayanan Balathandayuthapani |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Raspberry pi 2B |
||
| Issue Links: |
|
||||
| Description |
|
I create three tables:
and running theese commands:
As seen the table "child" disappeared, and can't recreate. |
| Comments |
| Comment by Elena Stepanova [ 2020-06-18 ] | |||||||||||||||||||||||||||||||
|
Thanks for the report. Reproducible as described. | |||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2020-06-18 ] | |||||||||||||||||||||||||||||||
|
The problem was first introduced in 10.0.38 by this commit:
At the beginning there was a debug assertion happening even earlier, on DROP PRIMARY KEY, but the release build would eventually end up with the lost table. | |||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2020-06-30 ] | |||||||||||||||||||||||||||||||
|
The following test case repeats the same scenaro without triggering
I added the root cause in test case. If foreign_key_check is disabled then inplace algorithm doesn't check for FK relation. It leads to contain | |||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2020-07-06 ] | |||||||||||||||||||||||||||||||
|
Patch is in bb-10.1-thiru | |||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-07-13 ] | |||||||||||||||||||||||||||||||
|
Can we fix this by passing a different parameter to the following call, to also evaluate new_is_tmp?
I think that we should try to avoid the following change:
Perhaps we should simply implement this check already in ha_innobase::create() when the #sql table is being created? That could let us to skip the dict_load_foreigns() call altogether on ALTER TABLE. Also, please try to write a clear commit message (or include in the commit a test case) that explains exactly what was wrong and how we are improving it. There are two rename operations in ALTER TABLE…ALGORITHM=COPY, and the above code snippet does not say which one it is referring to. | |||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2020-08-06 ] | |||||||||||||||||||||||||||||||
|
Patch is in bb-10.2- | |||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-08-07 ] | |||||||||||||||||||||||||||||||
|
The suggested fix affects not only ALTER TABLE but also RENAME TABLE. Also, it would seem to make part of a subsequent condition !old_is_tmp || trx->check_foreigns redundant and invalidate the immediately following comment:
Instead of this change, could we improve the error handling of the dict_load_foreigns() call? That is, when foreign key checks are disabled, display warning messages instead of error messages, and do not attempt to roll back the operation? And maybe simply pass the parameter check_charsets=!old_is_tmp to that call? | |||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2020-08-13 ] | |||||||||||||||||||||||||||||||
|
The tree commit 935415a9cdecf87a66166921e3f7594bf80fce77 (HEAD, origin/bb-10.2-thiru) |