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

Making FLUSH TABLES WITH READ LOCK block COMMITs of existing transactions,

in a deadlock-free manner. This splits locking the global read lock in two steps.
This fixes a consequence of this bug, known as:
BUG#4953 'mysqldump --master-data may report incorrect binlog position if using InnoDB'
And a test.
This commit is contained in:
guilhem@mysql.com
2004-08-20 16:35:23 +02:00
parent 96a000ae78
commit 5db56a106b
9 changed files with 154 additions and 21 deletions

View File

@@ -342,17 +342,30 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
#ifdef USING_TRANSACTIONS
if (opt_using_transactions)
{
bool operation_done= 0;
bool operation_done= 0, need_start_waiters= 0;
bool transaction_commited= 0;
/* Update the binary log if we have cached some queries */
if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
/* If transaction has done some updates to tables */
if (trans == &thd->transaction.all &&
my_b_tell(&thd->transaction.trans_log))
{
mysql_bin_log.write(thd, &thd->transaction.trans_log, 1);
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
if (error= wait_if_global_read_lock(thd, 0, 0))
{
/*
Note that ROLLBACK [TO SAVEPOINT] does not have this test; it's
because ROLLBACK never updates data, so needn't wait on the lock.
*/
my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
error= 1;
}
else
need_start_waiters= 1;
if (mysql_bin_log.is_open())
{
mysql_bin_log.write(thd, &thd->transaction.trans_log, 1);
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
}
}
#ifdef HAVE_BERKELEY_DB
if (trans->bdb_tid)
@@ -393,6 +406,8 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
statistic_increment(ha_commit_count,&LOCK_status);
thd->transaction.cleanup();
}
if (need_start_waiters)
start_waiting_global_read_lock(thd);
}
#endif // using transactions
DBUG_RETURN(error);