Commit cded083a authored by Monty's avatar Monty

MDEV-15797 Assertion `thd->killed != 0' failed in ha_maria::enable_indexes

Problem was that a parallel open of a table, overwrote info->state that
was in used by repair.

Fixed by changing _ma_tmp_disable_logging_for_table() to use
a new state buffer state.no_logging to store the temporary state.

Other things:
- Use original number of rows when retrying repair to get rid of a
  potential warning "Number of rows changed from X to Y"
- Changed maria_commit() to make it easier to merge with 10.4
- If table is not locked (like with show commands), use the global
  number of rows as the local number may not be up to date.
  (Minor not critical fix)
- Added some missing DBUG_RETURN
parent b87b8c13
CREATE TABLE t1 (a INT, b CHAR(12), c INT, FULLTEXT KEY(b), KEY (c)) ENGINE=Aria;
CREATE TABLE t2 (a INT, b CHAR(12), c INT) ENGINE=Aria;
INSERT INTO t2 VALUES (1,'foo',8), (2,'bar',9);
INSERT INTO t1 SELECT * FROM t2;
select 1;
1
1
select 1;
1
1
select 1;
1
1
select 1;
1
1
select 1;
1
1
select 1;
1
1
select 1;
1
1
SELECT * FROM t1 WHERE a = ( SELECT 1 FROM non_existing_table2 );
ERROR 42S02: Table 'test.non_existing_table2' doesn't exist
DROP TABLE t1, t2;
#
# MDEV-15797 Assertion `thd->killed != 0' failed in ha_maria::enable_indexes
#
CREATE TABLE t1 (a INT, b CHAR(12), c INT, FULLTEXT KEY(b), KEY (c)) ENGINE=Aria;
CREATE TABLE t2 (a INT, b CHAR(12), c INT) ENGINE=Aria;
INSERT INTO t2 VALUES (1,'foo',8), (2,'bar',9);
--connect (con1,localhost,root,,test)
--send
INSERT INTO t1 SELECT * FROM t2;
--connection default
select 1;
select 1;
select 1;
select 1;
select 1;
select 1;
select 1;
--error ER_NO_SUCH_TABLE
SELECT * FROM t1 WHERE a = ( SELECT 1 FROM non_existing_table2 );
--connection con1
--reap
# Cleanup
--disconnect con1
--connection default
DROP TABLE t1, t2;
......@@ -1460,6 +1460,7 @@ int ha_maria::repair(THD * thd, HA_CHECK_OPT *check_opt)
while ((error= repair(thd, param, 0)) && param->retry_repair)
{
param->retry_repair= 0;
file->state->records= start_records;
if (test_all_bits(param->testflag,
(uint) (T_RETRY_WITHOUT_QUICK | T_QUICK)))
{
......@@ -1961,6 +1962,7 @@ int ha_maria::disable_indexes(uint mode)
int ha_maria::enable_indexes(uint mode)
{
int error;
ha_rows start_rows= file->state->records;
DBUG_PRINT("info", ("ha_maria::enable_indexes mode: %d", mode));
if (maria_is_all_keys_active(file->s->state.key_map, file->s->base.keys))
{
......@@ -2023,6 +2025,7 @@ int ha_maria::enable_indexes(uint mode)
DBUG_ASSERT(thd->killed != 0);
/* Repairing by sort failed. Now try standard repair method. */
param->testflag &= ~T_REP_BY_SORT;
file->state->records= start_rows;
error= (repair(thd, param, 0) != HA_ADMIN_OK);
/*
If the standard repair succeeded, clear all error messages which
......
......@@ -98,7 +98,7 @@ int maria_commit(MARIA_HA *info)
if (!info->s->now_transactional)
return 0;
trn= info->trn;
info->trn= 0; /* checked in maria_close() */
_ma_reset_trn_for_table(info);
return ma_commit(trn);
}
......
......@@ -56,7 +56,11 @@ int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag)
}
if (flag & HA_STATUS_VARIABLE)
{
x->records = info->state->records;
/* If table is locked, give versioned number otherwise last commited */
if (info->lock_type == F_UNLCK)
x->records = share->state.state.records;
else
x->records = info->state->records;
x->deleted = share->state.state.del;
x->delete_length = share->state.state.empty;
x->data_file_length = share->state.state.data_file_length;
......
......@@ -3551,8 +3551,8 @@ void _ma_tmp_disable_logging_for_table(MARIA_HA *info,
info->state may point to a state that was deleted by
_ma_trnman_end_trans_hook()
*/
share->state.common= *info->state;
info->state= &share->state.common;
share->state.no_logging= *info->state;
info->state= &share->state.no_logging;
info->switched_transactional= TRUE;
/*
......@@ -3608,6 +3608,10 @@ my_bool _ma_reenable_logging_for_table(MARIA_HA *info, my_bool flush_pages)
_ma_copy_nontrans_state_information(info);
_ma_reset_history(info->s);
/* Reset state to point to state.common, as on open() */
info->state= &share->state.common;
*info->state= share->state.state;
if (flush_pages)
{
/* Ensure that recover is not executing any redo before this */
......
......@@ -1128,7 +1128,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
{
fprintf(stderr, "Aria table '%s' is not fixed because of errors\n",
filename);
return(-1);
DBUG_RETURN(-1);
}
recreate=1;
if (!(param->testflag & T_REP_ANY))
......@@ -1150,7 +1150,7 @@ static int maria_chk(HA_CHECK *param, char *filename)
param->total_deleted+=info->state->del;
descript(param, info, filename);
maria_close(info); /* Should always succeed */
return(0);
DBUG_RETURN(0);
}
if (!stopwords_inited++)
......
......@@ -149,6 +149,8 @@ typedef struct st_maria_state_info
MARIA_STATUS_INFO state;
/* maria_ha->state points here for crash-safe but not versioned tables */
MARIA_STATUS_INFO common;
/* State for a versioned table that is temporary non versioned */
MARIA_STATUS_INFO no_logging;
ha_rows split; /* number of split blocks */
my_off_t dellink; /* Link to next removed block */
pgcache_page_no_t first_bitmap_with_space;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment