mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV 15532 Assertion `!log->same_pk' failed in row_log_table_apply_delete
The reason for the failure is that thd->mdl_context.release_transactional_locks() was called after commit & rollback even in cases where the current transaction is still active. For 10.2, 10.3 and 10.4 the fix is simple: - Replace all calls to thd->mdl_context.release_transactional_locks() with thd->release_transactional_locks(). The thd function will only call the mdl_context function if there are no active transactional locks. In 10.6 we will better fix where we will change the return value for some trans_xxx() functions to indicate if transaction did close the transaction or not. This will avoid the need of the indirect call. Other things: - trans_xa_commit() and trans_xa_rollback() will automatically call release_transactional_locks() if the transaction is closed. - We can't do that for the other functions as the caller of many of these are doing additional work (like close_thread_tables) before calling release_transactional_locks(). - Added missing abort_result_set() and missing DBUG_RETURN in select_create::send_eof() - Fixed wrong indentation in injector::transaction::commit()
This commit is contained in:
@@ -2034,7 +2034,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
locks.
|
||||
*/
|
||||
trans_rollback_implicit(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
}
|
||||
|
||||
thd->cleanup_after_query();
|
||||
@@ -2099,7 +2099,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
ulonglong options= (ulonglong) (uchar) packet[0];
|
||||
if (trans_commit_implicit(thd))
|
||||
break;
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
if (check_global_access(thd,RELOAD_ACL))
|
||||
break;
|
||||
general_log_print(thd, command, NullS);
|
||||
@@ -2132,7 +2132,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
||||
if (trans_commit_implicit(thd))
|
||||
break;
|
||||
close_thread_tables(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
my_ok(thd);
|
||||
break;
|
||||
}
|
||||
@@ -2934,7 +2934,7 @@ err:
|
||||
/* Close tables and release metadata locks. */
|
||||
close_thread_tables(thd);
|
||||
DBUG_ASSERT(!thd->locked_tables_mode);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -3406,7 +3406,7 @@ mysql_execute_command(THD *thd)
|
||||
/* Commit the normal transaction if one is active. */
|
||||
bool commit_failed= trans_commit_implicit(thd);
|
||||
/* Release metadata locks acquired in this transaction. */
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
if (commit_failed)
|
||||
{
|
||||
WSREP_DEBUG("implicit commit failed, MDL released: %lld",
|
||||
@@ -4645,7 +4645,7 @@ mysql_execute_command(THD *thd)
|
||||
{
|
||||
res= trans_commit_implicit(thd);
|
||||
thd->locked_tables_list.unlock_locked_tables(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
thd->variables.option_bits&= ~(OPTION_TABLE_LOCK);
|
||||
}
|
||||
if (thd->global_read_lock.is_acquired())
|
||||
@@ -4659,7 +4659,7 @@ mysql_execute_command(THD *thd)
|
||||
res= trans_commit_implicit(thd);
|
||||
thd->locked_tables_list.unlock_locked_tables(thd);
|
||||
/* Release transactional metadata locks. */
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
if (res)
|
||||
goto error;
|
||||
|
||||
@@ -5313,7 +5313,7 @@ mysql_execute_command(THD *thd)
|
||||
DBUG_PRINT("info", ("Executing SQLCOM_BEGIN thd: %p", thd));
|
||||
if (trans_begin(thd, lex->start_transaction_opt))
|
||||
{
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
WSREP_DEBUG("BEGIN failed, MDL released: %lld",
|
||||
(longlong) thd->thread_id);
|
||||
goto error;
|
||||
@@ -5331,7 +5331,7 @@ mysql_execute_command(THD *thd)
|
||||
(thd->variables.completion_type == 2 &&
|
||||
lex->tx_release != TVL_NO));
|
||||
bool commit_failed= trans_commit(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
if (commit_failed)
|
||||
{
|
||||
WSREP_DEBUG("COMMIT failed, MDL released: %lld",
|
||||
@@ -5382,7 +5382,7 @@ mysql_execute_command(THD *thd)
|
||||
(thd->variables.completion_type == 2 &&
|
||||
lex->tx_release != TVL_NO));
|
||||
bool rollback_failed= trans_rollback(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
|
||||
if (rollback_failed)
|
||||
{
|
||||
@@ -5859,7 +5859,6 @@ mysql_execute_command(THD *thd)
|
||||
case SQLCOM_XA_COMMIT:
|
||||
{
|
||||
bool commit_failed= trans_xa_commit(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
if (commit_failed)
|
||||
{
|
||||
WSREP_DEBUG("XA commit failed, MDL released: %lld",
|
||||
@@ -5877,7 +5876,6 @@ mysql_execute_command(THD *thd)
|
||||
case SQLCOM_XA_ROLLBACK:
|
||||
{
|
||||
bool rollback_failed= trans_xa_rollback(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
if (rollback_failed)
|
||||
{
|
||||
WSREP_DEBUG("XA rollback failed, MDL released: %lld",
|
||||
@@ -6095,7 +6093,7 @@ finish:
|
||||
all storage engines including binary log.
|
||||
*/
|
||||
trans_rollback_implicit(thd);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
}
|
||||
else if (stmt_causes_implicit_commit(thd, CF_IMPLICIT_COMMIT_END))
|
||||
{
|
||||
@@ -6108,7 +6106,7 @@ finish:
|
||||
/* Commit the normal transaction if one is active. */
|
||||
trans_commit_implicit(thd);
|
||||
thd->get_stmt_da()->set_overwrite_status(false);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
}
|
||||
}
|
||||
else if (! thd->in_sub_stmt && ! thd->in_multi_stmt_transaction_mode())
|
||||
@@ -6123,7 +6121,7 @@ finish:
|
||||
- If in autocommit mode, or outside a transactional context,
|
||||
automatically release metadata locks of the current statement.
|
||||
*/
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
}
|
||||
else if (! thd->in_sub_stmt)
|
||||
{
|
||||
@@ -6145,7 +6143,7 @@ finish:
|
||||
{
|
||||
WSREP_DEBUG("Forcing release of transactional locks for thd: %lld",
|
||||
(longlong) thd->thread_id);
|
||||
thd->mdl_context.release_transactional_locks();
|
||||
thd->release_transactional_locks();
|
||||
}
|
||||
#endif /* WITH_WSREP */
|
||||
|
||||
|
Reference in New Issue
Block a user