1
0
mirror of https://github.com/MariaDB/server.git synced 2025-06-16 11:21:15 +03:00

A pre-requisite patch for the fix for Bug#52044.

This patch also fixes Bug#55452 "SET PASSWORD is
replicated twice in RBR mode".

The goal of this patch is to remove the release of 
metadata locks from close_thread_tables().
This is necessary to not mistakenly release
the locks in the course of a multi-step
operation that involves multiple close_thread_tables()
or close_tables_for_reopen().

On the same token, move statement commit outside 
close_thread_tables().

Other cleanups:
Cleanup COM_FIELD_LIST.
Don't call close_thread_tables() in COM_SHUTDOWN -- there
are no open tables there that can be closed (we leave
the locked tables mode in THD destructor, and this
close_thread_tables() won't leave it anyway).

Make open_and_lock_tables() and open_and_lock_tables_derived()
call close_thread_tables() upon failure.
Remove the calls to close_thread_tables() that are now
unnecessary.

Simplify the back off condition in Open_table_context.

Streamline metadata lock handling in LOCK TABLES 
implementation.

Add asserts to ensure correct life cycle of 
statement transaction in a session.

Remove a piece of dead code that has also become redundant
after the fix for Bug 37521.
This commit is contained in:
Konstantin Osipov
2010-07-27 14:25:53 +04:00
parent c67cf159e9
commit ec2c3bf2c1
42 changed files with 590 additions and 468 deletions

View File

@ -59,7 +59,7 @@
#include "key.h" // key_copy
#include "sql_base.h" // insert_fields
#include "sql_select.h"
#include <assert.h>
#include "transaction.h"
#define HANDLER_TABLES_HASH_SIZE 120
@ -309,9 +309,15 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen)
}
if (error)
{
/*
No need to rollback statement transaction, it's not started.
If called with reopen flag, no need to rollback either,
it will be done at statement end.
*/
DBUG_ASSERT(thd->transaction.stmt.is_empty());
close_thread_tables(thd);
thd->set_open_tables(backup_open_tables);
thd->mdl_context.rollback_to_savepoint(mdl_savepoint);
thd->set_open_tables(backup_open_tables);
if (!reopen)
my_hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables);
else
@ -578,6 +584,11 @@ retry:
if (sql_handler_lock_error.need_reopen())
{
DBUG_ASSERT(!lock && !thd->is_error());
/*
Always close statement transaction explicitly,
so that the engine doesn't have to count locks.
*/
trans_rollback_stmt(thd);
mysql_ha_close_table(thd, hash_tables);
goto retry;
}
@ -764,12 +775,18 @@ retry:
num_rows++;
}
ok:
/*
Always close statement transaction explicitly,
so that the engine doesn't have to count locks.
*/
trans_commit_stmt(thd);
mysql_unlock_tables(thd,lock);
my_eof(thd);
DBUG_PRINT("exit",("OK"));
DBUG_RETURN(FALSE);
err:
trans_rollback_stmt(thd);
mysql_unlock_tables(thd,lock);
err0:
DBUG_PRINT("exit",("ERROR"));