Commit 4524db23 authored by Michael Widenius's avatar Michael Widenius

Fixed MDEV-306 / LP:1007967 - Assertion `table->file->stats.records > 0 ||...

Fixed MDEV-306 / LP:1007967 - Assertion `table->file->stats.records > 0 || error' failed join_read_const_table on concurrent SELECT and DROP/ADD INDEX


sql/sql_table.cc:
  Added comment
storage/maria/ma_close.c:
  Don't store history if it's visible to all.
  This fixed the MDEV-306 bug
storage/maria/ma_delete_table.c:
  Removed old comment
  Delete history state for deleted tables
storage/maria/ma_info.c:
  More DBUG_PRINT
storage/maria/ma_open.c:
  More DBUG_PRINT
parent 6e719145
...@@ -7360,7 +7360,10 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to, ...@@ -7360,7 +7360,10 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
thd_progress_next_stage(thd); thd_progress_next_stage(thd);
if (error > 0) if (error > 0)
{
/* We are going to drop the temporary table */
to->file->extra(HA_EXTRA_PREPARE_FOR_DROP); to->file->extra(HA_EXTRA_PREPARE_FOR_DROP);
}
if (errpos >= 3 && to->file->ha_end_bulk_insert() && error <= 0) if (errpos >= 3 && to->file->ha_end_bulk_insert() && error <= 0)
{ {
to->file->print_error(my_errno,MYF(0)); to->file->print_error(my_errno,MYF(0));
......
...@@ -193,9 +193,10 @@ int maria_close(register MARIA_HA *info) ...@@ -193,9 +193,10 @@ int maria_close(register MARIA_HA *info)
else else
share_can_be_freed= TRUE; share_can_be_freed= TRUE;
if (share->state_history) if (share->state_history && share->state_history->trid)
{ {
MARIA_STATE_HISTORY_CLOSED *history; MARIA_STATE_HISTORY_CLOSED *history;
DBUG_PRINT("info", ("Storing state history"));
/* /*
Here we ignore the unlikely case that we don't have memory to Here we ignore the unlikely case that we don't have memory to
store the state. In the worst case what happens is that any transaction store the state. In the worst case what happens is that any transaction
......
...@@ -38,14 +38,8 @@ int maria_delete_table(const char *name) ...@@ -38,14 +38,8 @@ int maria_delete_table(const char *name)
/** @todo LOCK take X-lock on table */ /** @todo LOCK take X-lock on table */
/* /*
We need to know if this table is transactional. We need to know if this table is transactional.
When built with RAID support, we also need to determine if this table Unfortunately it is necessary to open the table just to check this. We use
makes use of the raid feature. If yes, we need to remove all raid 'open_for_repair' to be able to open even a crashed table.
chunks. This is done with my_raid_delete(). Unfortunately it is
necessary to open the table just to check this. We use
'open_for_repair' to be able to open even a crashed table. If even
this open fails, we assume no raid configuration for this table
and try to remove the normal data file only. This may however
leave the raid chunks behind.
*/ */
if (!(info= maria_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR))) if (!(info= maria_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR)))
{ {
...@@ -56,6 +50,8 @@ int maria_delete_table(const char *name) ...@@ -56,6 +50,8 @@ int maria_delete_table(const char *name)
sync_dir= (info->s->now_transactional && !info->s->temporary && sync_dir= (info->s->now_transactional && !info->s->temporary &&
!maria_in_recovery) ? !maria_in_recovery) ?
MY_SYNC_DIR : 0; MY_SYNC_DIR : 0;
/* Remove history for table */
_ma_reset_state(info);
maria_close(info); maria_close(info);
} }
......
...@@ -42,6 +42,7 @@ int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag) ...@@ -42,6 +42,7 @@ int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag)
MY_STAT state; MY_STAT state;
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
DBUG_ENTER("maria_status"); DBUG_ENTER("maria_status");
DBUG_PRINT("info", ("records: %lld", info->state->records));
x->recpos= info->cur_row.lastpos; x->recpos= info->cur_row.lastpos;
if (flag == HA_STATUS_POS) if (flag == HA_STATUS_POS)
......
...@@ -866,6 +866,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -866,6 +866,9 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
_ma_remove_not_visible_states(history->state_history, 0, 0); _ma_remove_not_visible_states(history->state_history, 0, 0);
history->state_history= 0; history->state_history= 0;
(void) my_hash_delete(&maria_stored_state, (uchar*) history); (void) my_hash_delete(&maria_stored_state, (uchar*) history);
DBUG_PRINT("info", ("Reading state history. trid: %lu records: %lld",
(ulong) share->state_history->trid,
share->state_history->state.records));
} }
else else
{ {
...@@ -988,6 +991,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -988,6 +991,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
mysql_mutex_unlock(&THR_LOCK_maria); mysql_mutex_unlock(&THR_LOCK_maria);
m_info->open_flags= open_flags; m_info->open_flags= open_flags;
DBUG_PRINT("exit", ("table: %p name: %s",m_info, name));
DBUG_RETURN(m_info); DBUG_RETURN(m_info);
err: err:
......
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