mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
Fixed lp:947474 "Assertion `table->file->stats.records > 0 || error' failed in join_read_const_table on concurrent SELECT and ALTER, constant Aria table"
Remove Aria state history for drop/rename mysql-test/suite/maria/r/maria-recovery2.result: Updated old (wrong) test result sql/handler.cc: Fixed wrong argument to implict_commit storage/maria/ha_maria.cc: Ensure that we don't use file->trn if THD_TRN is 0. (This means that implict_commit() has been called and the trn object is not ours anymore) storage/maria/ma_extra.c: Remove Aria state history for drop/rename storage/maria/ma_rename.c: Remove Aria state history for rename storage/maria/ma_state.c: More DBUG_PRINT
This commit is contained in:
@@ -84,10 +84,11 @@ Table Op Msg_type Msg_text
|
|||||||
mysqltest.t1 check status OK
|
mysqltest.t1 check status OK
|
||||||
* testing that checksum after recovery is as expected
|
* testing that checksum after recovery is as expected
|
||||||
Checksum-check
|
Checksum-check
|
||||||
ok
|
failure
|
||||||
use mysqltest;
|
use mysqltest;
|
||||||
select * from t1;
|
select * from t1;
|
||||||
a
|
a
|
||||||
|
1
|
||||||
3
|
3
|
||||||
drop table t1;
|
drop table t1;
|
||||||
* TEST of recovery when crash before bulk-insert-with-repair is committed
|
* TEST of recovery when crash before bulk-insert-with-repair is committed
|
||||||
|
@@ -1185,7 +1185,7 @@ int ha_commit_trans(THD *thd, bool all)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_ARIA_STORAGE_ENGINE
|
#ifdef WITH_ARIA_STORAGE_ENGINE
|
||||||
ha_maria::implicit_commit(thd, FALSE);
|
ha_maria::implicit_commit(thd, TRUE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ha_info)
|
if (!ha_info)
|
||||||
|
@@ -2463,18 +2463,26 @@ int ha_maria::extra(enum ha_extra_function operation)
|
|||||||
without calling commit/rollback in between. If file->trn is not set
|
without calling commit/rollback in between. If file->trn is not set
|
||||||
we can't remove file->share from the transaction list in the extra() call.
|
we can't remove file->share from the transaction list in the extra() call.
|
||||||
|
|
||||||
|
We also ensure that we set file->trn to 0 if THD_TRN is 0 as in
|
||||||
|
this case we have already freed the trn. This can happen when one
|
||||||
|
implicit_commit() is called as part of alter table.
|
||||||
|
|
||||||
table->in_use is not set in the case this is a done as part of closefrm()
|
table->in_use is not set in the case this is a done as part of closefrm()
|
||||||
as part of drop table.
|
as part of drop table.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (file->s->now_transactional && !file->trn && table->in_use &&
|
if (file->s->now_transactional && table->in_use &&
|
||||||
(operation == HA_EXTRA_PREPARE_FOR_DROP ||
|
(operation == HA_EXTRA_PREPARE_FOR_DROP ||
|
||||||
operation == HA_EXTRA_PREPARE_FOR_RENAME))
|
operation == HA_EXTRA_PREPARE_FOR_RENAME ||
|
||||||
|
operation == HA_EXTRA_PREPARE_FOR_FORCED_CLOSE))
|
||||||
{
|
{
|
||||||
THD *thd= table->in_use;
|
THD *thd= table->in_use;
|
||||||
TRN *trn= THD_TRN;
|
TRN *trn= THD_TRN;
|
||||||
_ma_set_trn_for_table(file, trn);
|
_ma_set_trn_for_table(file, trn);
|
||||||
}
|
}
|
||||||
|
DBUG_ASSERT(file->s->base.born_transactional || file->trn == 0 ||
|
||||||
|
file->trn == &dummy_transaction_object);
|
||||||
|
|
||||||
tmp= maria_extra(file, operation, 0);
|
tmp= maria_extra(file, operation, 0);
|
||||||
file->trn= old_trn; // Reset trn if was used
|
file->trn= old_trn; // Reset trn if was used
|
||||||
return tmp;
|
return tmp;
|
||||||
@@ -2767,6 +2775,11 @@ int ha_maria::implicit_commit(THD *thd, bool new_trn)
|
|||||||
error= 1;
|
error= 1;
|
||||||
if (!new_trn)
|
if (!new_trn)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
To be extra safe, we should also reset file->trn for all open
|
||||||
|
tables as some calls, like extra() may access it. We take care
|
||||||
|
of this in extra() by resetting file->trn if THD_TRN is 0.
|
||||||
|
*/
|
||||||
THD_TRN= NULL;
|
THD_TRN= NULL;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@@ -348,6 +348,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
|
|||||||
/* Ensure we don't point to the deleted data in trn */
|
/* Ensure we don't point to the deleted data in trn */
|
||||||
info->state= info->state_start= &share->state.state;
|
info->state= info->state_start= &share->state.state;
|
||||||
}
|
}
|
||||||
|
/* Remove history for table */
|
||||||
|
_ma_reset_state(info);
|
||||||
|
|
||||||
type= do_flush ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED;
|
type= do_flush ? FLUSH_RELEASE : FLUSH_IGNORE_CHANGED;
|
||||||
save_global_changed= share->global_changed;
|
save_global_changed= share->global_changed;
|
||||||
|
@@ -103,6 +103,7 @@ int maria_rename(const char *old_name, const char *new_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_ma_reset_state(info);
|
||||||
maria_close(info);
|
maria_close(info);
|
||||||
|
|
||||||
fn_format(from,old_name,"",MARIA_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
|
fn_format(from,old_name,"",MARIA_NAME_IEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT);
|
||||||
|
@@ -229,13 +229,14 @@ void _ma_remove_not_visible_states_with_lock(MARIA_SHARE *share,
|
|||||||
to current state.
|
to current state.
|
||||||
|
|
||||||
@notes
|
@notes
|
||||||
Used after repair as then all rows are visible for everyone
|
Used after repair/rename/drop as then all rows are visible for everyone
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _ma_reset_state(MARIA_HA *info)
|
void _ma_reset_state(MARIA_HA *info)
|
||||||
{
|
{
|
||||||
MARIA_SHARE *share= info->s;
|
MARIA_SHARE *share= info->s;
|
||||||
MARIA_STATE_HISTORY *history= share->state_history;
|
MARIA_STATE_HISTORY *history= share->state_history;
|
||||||
|
DBUG_ENTER("_ma_reset_state");
|
||||||
|
|
||||||
if (history)
|
if (history)
|
||||||
{
|
{
|
||||||
@@ -253,6 +254,7 @@ void _ma_reset_state(MARIA_HA *info)
|
|||||||
share->state_history->next= 0;
|
share->state_history->next= 0;
|
||||||
share->state_history->trid= 0; /* Visibile for all */
|
share->state_history->trid= 0; /* Visibile for all */
|
||||||
}
|
}
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -433,6 +435,7 @@ my_bool _ma_trnman_end_trans_hook(TRN *trn, my_bool commit,
|
|||||||
my_bool error= 0;
|
my_bool error= 0;
|
||||||
MARIA_USED_TABLES *tables, *next;
|
MARIA_USED_TABLES *tables, *next;
|
||||||
DBUG_ENTER("_ma_trnman_end_trans_hook");
|
DBUG_ENTER("_ma_trnman_end_trans_hook");
|
||||||
|
DBUG_PRINT("enter", ("trn: %p used_tables: %p", trn, trn->used_tables));
|
||||||
|
|
||||||
for (tables= (MARIA_USED_TABLES*) trn->used_tables;
|
for (tables= (MARIA_USED_TABLES*) trn->used_tables;
|
||||||
tables;
|
tables;
|
||||||
@@ -547,8 +550,8 @@ void _ma_remove_table_from_trnman(MARIA_SHARE *share, TRN *trn)
|
|||||||
{
|
{
|
||||||
MARIA_USED_TABLES *tables, **prev;
|
MARIA_USED_TABLES *tables, **prev;
|
||||||
DBUG_ENTER("_ma_remove_table_from_trnman");
|
DBUG_ENTER("_ma_remove_table_from_trnman");
|
||||||
DBUG_PRINT("enter", ("share: 0x%lx in_trans: %d",
|
DBUG_PRINT("enter", ("trn: %p used_tables: %p share: %p in_trans: %d",
|
||||||
(ulong) share, share->in_trans));
|
trn, trn->used_tables, share, share->in_trans));
|
||||||
|
|
||||||
mysql_mutex_assert_owner(&share->intern_lock);
|
mysql_mutex_assert_owner(&share->intern_lock);
|
||||||
|
|
||||||
@@ -560,7 +563,6 @@ void _ma_remove_table_from_trnman(MARIA_SHARE *share, TRN *trn)
|
|||||||
{
|
{
|
||||||
*prev= tables->next;
|
*prev= tables->next;
|
||||||
share->in_trans--;
|
share->in_trans--;
|
||||||
DBUG_PRINT("info", ("in_trans: %d", share->in_trans));
|
|
||||||
my_free(tables);
|
my_free(tables);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -730,6 +732,10 @@ void _ma_copy_nontrans_state_information(MARIA_HA *info)
|
|||||||
info->s->state.state.checksum= info->state->checksum;
|
info->s->state.state.checksum= info->state->checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reset history
|
||||||
|
This is only called during repair when we the only one using the table.
|
||||||
|
*/
|
||||||
|
|
||||||
void _ma_reset_history(MARIA_SHARE *share)
|
void _ma_reset_history(MARIA_SHARE *share)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user