[MDEV-14310] Possible corruption by table-rebuilding or index-creating ALTER TABLE…ALGORITHM=INPLACE Created: 2017-11-07 Updated: 2017-11-20 Resolved: 2017-11-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.2.11, 10.3.3 |
| Fix Version/s: | 10.2.11, 10.3.3 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | corruption, ddl, performance | ||
| Attachments: |
|
||||||||||||
| Issue Links: |
|
||||||||||||
| Description |
|
When I merged The culprit seemed to be a correct-looking conflict resolution in FlushObserver::flush(). As part of the test, innodb.innodb is executing the following:
This includes the following:
The duplicate key error triggers the following code at the end of row_merge_build_indexes():
This in turn causes a choice of a dangerous parameter:
The danger here is that m_space_id=0, the system tablespace. This is potentially discarding other writes to the InnoDB system tablespace, potentially corrupting the whole instance. We must use the equivalent of BUF_REMOVE_FLUSH_WRITE for the system tablespace (and in MySQL 5.7, for any table that resides in a persistent shared tablespace). Failure to do so caused all sorts of trouble when running innodb.innodb after the merge, especially when using --innodb-buffer-pool-size=5m (the minimum).
Various assertions failed due to a supposedly-initialized page being all-zero. Note: For a failed ALTER TABLE in a tablename.ibd file, it is perfectly OK to discard the entries from the flush_list, and to subsequently mark the pages as freed, or to delete the file (if it was a table-rebuilding ALTER). |
| Comments |
| Comment by Marko Mäkelä [ 2017-11-07 ] |
|
Actually, the impact of this bug is more widespread than I initially thought. Also locking ALGORITHM=INPLACE operations with innodb_file_per_table=1 may be affected, because LOCK=SHARED or LOCK=EXCLUSIVE does not prevent purge or change buffer merge from running. Any ALGORITHM=INPLACE operation that involves ADD UNIQUE INDEX or ADD INDEX or rebuilding the table is potentially affected. |
| Comment by Marko Mäkelä [ 2017-11-20 ] |
|
This turned out to be a merge error of |
| Comment by Marko Mäkelä [ 2017-11-20 ] |
|
I tested upstream (MySQL 5.7) by porting two commits from MariaDB 10.1 to MySQL 5.6 (0001-Remove-redundant-function-parameters.patch |