[MDEV-28727] ALTER TABLE ALGORITHM=NOCOPY does not work after upgrade Created: 2022-06-02 Updated: 2023-07-05 Resolved: 2022-08-02 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 10.4.25, 10.5, 10.6, 10.7, 10.8, 10.9 |
| Fix Version/s: | 10.4.26, 10.5.17, 10.6.9, 10.7.5, 10.8.4, 10.9.2 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Allen Lee (Inactive) | Assignee: | Aleksey Midenkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | rr-profile-analyzed, upgrade | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
Here is the repro step. 1) install 10.1.4 using binary tarballs.
3) upgrade the instance with 10.4.25. This can be done by yum/rpm install.
#4 works without error, when create is created with v10.4.25.
|
| Comments |
| Comment by Marko Mäkelä [ 2022-06-03 ] | |||||||||||||||||||||||
|
Is this repeatable when starting with 10.1.21 or later? I am asking because of Could you please attach a copy of the data directory before step 3? | |||||||||||||||||||||||
| Comment by Rob Schwyzer [ 2022-06-03 ] | |||||||||||||||||||||||
|
Provided requested feedback. | |||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-06-07 ] | |||||||||||||||||||||||
|
I can reproduce this with CS0404325.tar.gz
The culprit is instant_alter_column_possible(), which returns false here (tested in 10.6):
The flags are 0x41800000000 and the allowed flags are as follows:
That is, the flag 0x800000000 is not expected:
That flag was set here:
The SQL layer appears to ‘think’ that adding a column will require an index to be created, even though it is absolutely not necessary here. I am not at all familiar with the code outside InnoDB, and the .frm file. I do not think that anything changed on the InnoDB side with respect to this. | |||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2022-06-21 ] | |||||||||||||||||||||||
|
Sorry, that was wrong flag described in the deleted comment. Until | |||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2022-06-21 ] | |||||||||||||||||||||||
|
"ALTER TABLE pet4 FORCE (no algorithm option)" does HA_ALTER_INPLACE_COPY_NO_LOCK which means it rebuilds clustered index (and secondary indexes always/if needed, marko please correct me). The simplest way to check if the table is affected by
if it fails with error
then the table is affected by the bug. If it doesn't fail, the table is OK for more NOCOPY operations. Since FORCE is NOCOPY itself it will be fast in any case. If you want to check the table and don't even rewrite FRM, this is possible with debug build:
this may result in two errors:
By error code 1845 or 1105 you can filter out tables programmatically.
| |||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2022-06-25 ] | |||||||||||||||||||||||
|
rob.schwyzer@mariadb.com Hmm, I prepared an answer for `alter_table_rollback_new_index` check and suddenly got an idea that `ALTER TABLE FORCE` can be possible just for `ALGORITHM=NOCOPY`. I did not even suspect that it might not be supported, my apologies. So, my second part about debug build and `alter_table_rollback_new_index` check is still true. As for non-debug build you may do an instant add and drop column instead:
| |||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2022-06-29 ] | |||||||||||||||||||||||
|
#1. cannot be done without #3. According to | |||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2022-06-29 ] | |||||||||||||||||||||||
|
#3 is a feature (if it will not be separate binary which fixes FRMs but even in this case I'd abstain from running it for all users) and 10.5 is not the version where we add new features (can be exceptions). May be we can add ignoring flags which are not supported by an engine (for now I have no ideas how it can be implemeted, maybe special constant in engine to make bit AND with flags written in the frm)... | |||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2022-07-20 ] | |||||||||||||||||||||||
|
Since there is no direct knowledge that only DOUBLE is affected ( 1. if FRM version is prior
2. mysqlcheck --auto-repair (and mysql_upgrade) when sees such table issues ALTER TABLE FORCE. | |||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2022-07-22 ] | |||||||||||||||||||||||
|
Please review bb-10.4-midenok2 | |||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2022-07-29 ] | |||||||||||||||||||||||
|
OK to push | |||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-08-16 ] | |||||||||||||||||||||||
|
Did I understand the fix correctly that it actually continues to require such tables to be rebuilt when upgrading the server? Is there any way to avoid unnecessarily rebuilding the data of the table, and to adjust or tolerate old-format .frm files? | |||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-09 ] | |||||||||||||||||||||||
|
I can still reproduce the reported problem with the following test:
This is with the pet4.frm from CS0404325.tar.gz
I intend to fix this in |