1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-17070 Table corruption or Assertion table->file->stats.records > 0 || error' or Assertion !is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon actions on temporary table

This was caused by a combination of factors:
* MyISAM/Aria temporary tables historically never saved the state
  to disk (MYI/MAI), because the state never needed to persist
* certain ALTER TABLE operations modify the original TABLE structure
  and if they fail, the original table has to be reopened to
  revert all changes (m_needs_reopen=1)

as a result, when ALTER fails and MyISAM/Aria temp table gets reopened,
it reads the stale state from the disk.

As a fix, MyISAM/Aria tables now *always* write the state to disk
on close, *unless* HA_EXTRA_PREPARE_FOR_DROP was done first. And
the server now always does HA_EXTRA_PREPARE_FOR_DROP before dropping
a temporary table.
This commit is contained in:
Sergei Golubchik
2019-03-10 18:55:35 +01:00
parent 7025a51a7b
commit 69abd43703
9 changed files with 117 additions and 33 deletions

View File

@ -190,3 +190,56 @@ NULL NULL
DROP TABLE t;
# Cleanup
DROP DATABASE temp_db;
USE test;
create temporary table t1 (f char(255), b int, index(b)) engine=MyISAM;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
alter table t1 change if exists a b int, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
f b
NULL 1
NULL 2
drop table t1;
create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=1;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
alter table t1 change if exists a b int, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
f b
NULL 1
NULL 2
drop table t1;
create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=page;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
alter table t1 change if exists a b int, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
f b
NULL 1
NULL 2
drop table t1;
create temporary table t1 (f char(255), b int, index(b)) engine=aria transactional=0 row_format=dynamic;
replace into t1 values (null,1),(null,2);
alter table t1 add fulltext key(f);
alter table t1 change if exists a b int, algorithm=inplace;
ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select * from t1;
f b
NULL 1
NULL 2
drop table t1;