Commit cab0fea9 authored by unknown's avatar unknown

Fixed mutex taking order on recovery of bulk insert.

storage/maria/ma_key_recover.c:
  Takes intern_lock before writing CLR_END of bulk insert.
  Added debug info about writing trigger.
  Check of mutex taken in _ma_state_info_write() where we need it.
parent 87161264
......@@ -123,12 +123,23 @@ my_bool _ma_write_clr(MARIA_HA *info, LSN undo_lsn,
log_array[TRANSLOG_INTERNAL_PARTS + 0].str= log_data;
log_array[TRANSLOG_INTERNAL_PARTS + 0].length= (uint) (log_pos - log_data);
/*
We need intern_lock mutex for calling _ma_state_info_write in the trigger.
We do it here to have the same sequence of mutexes locking everywhere
(first intern_lock then transactional log buffer lock)
*/
if (undo_type == LOGREC_UNDO_BULK_INSERT)
pthread_mutex_lock(&info->s->intern_lock);
res= translog_write_record(res_lsn, LOGREC_CLR_END,
info->trn, info,
(translog_size_t)
log_array[TRANSLOG_INTERNAL_PARTS + 0].length,
TRANSLOG_INTERNAL_PARTS + 1, log_array,
log_data + LSN_STORE_SIZE, &msg);
if (undo_type == LOGREC_UNDO_BULK_INSERT)
pthread_mutex_unlock(&info->s->intern_lock);
DBUG_RETURN(res);
}
......@@ -149,6 +160,7 @@ my_bool write_hook_for_clr_end(enum translog_record_type type
struct st_msg_to_write_hook_for_clr_end *msg=
(struct st_msg_to_write_hook_for_clr_end *)hook_arg;
my_bool error= FALSE;
DBUG_ENTER("write_hook_for_clr_end");
DBUG_ASSERT(trn->trid != 0);
trn->undo_lsn= msg->previous_undo_lsn;
......@@ -177,9 +189,10 @@ my_bool write_hook_for_clr_end(enum translog_record_type type
case LOGREC_UNDO_KEY_DELETE:
break;
case LOGREC_UNDO_BULK_INSERT:
safe_mutex_assert_owner(&share->intern_lock);
error= (maria_enable_indexes(tbl_info) ||
/* we enabled indices, need '2' below */
_ma_state_info_write(share, 1|2|4));
_ma_state_info_write(share, 1|2));
/* no need for _ma_reset_status(): REDO_DELETE_ALL is just before us */
break;
default:
......@@ -187,7 +200,7 @@ my_bool write_hook_for_clr_end(enum translog_record_type type
}
if (trn->undo_lsn == LSN_IMPOSSIBLE) /* has fully rolled back */
trn->first_undo_lsn= LSN_WITH_FLAGS_TO_FLAGS(trn->first_undo_lsn);
return error;
DBUG_RETURN(error);
}
......
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