summaryrefslogtreecommitdiff
path: root/sql/transaction.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-05-05 23:53:31 +0200
committerSergei Golubchik <sergii@pisem.net>2014-05-05 23:53:31 +0200
commit3792693f311a90cf195ec6d2f9b3762255a249c7 (patch)
tree6a7af45fff9c7ad7463310d1fe12e9d505547b2f /sql/transaction.cc
parentf90dca1a0d78f4af9ab4355aaf325839034147ce (diff)
downloadmariadb-git-3792693f311a90cf195ec6d2f9b3762255a249c7.tar.gz
merge MySQL-5.6 bugfix "Bug#17862905: MYSQLDUMP CREATES USELESS METADATA LOCKS"
revno: 5716 committer: Praveenkumar Hulakund <praveenkumar.hulakund@oracle.com> branch nick: mysql_5_6 timestamp: Sat 2013-12-28 22:08:40 +0530 message: Bug#17862905: MYSQLDUMP CREATES USELESS METADATA LOCKS
Diffstat (limited to 'sql/transaction.cc')
-rw-r--r--sql/transaction.cc35
1 files changed, 27 insertions, 8 deletions
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 3575ff52e66..933e39ae357 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -574,6 +574,32 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_STRING name)
DBUG_RETURN(TRUE);
}
+ /**
+ Checking whether it is safe to release metadata locks acquired after
+ savepoint, if rollback to savepoint is successful.
+
+ Whether it is safe to release MDL after rollback to savepoint depends
+ on storage engines participating in transaction:
+
+ - InnoDB doesn't release any row-locks on rollback to savepoint so it
+ is probably a bad idea to release MDL as well.
+ - Binary log implementation in some cases (e.g when non-transactional
+ tables involved) may choose not to remove events added after savepoint
+ from transactional cache, but instead will write them to binary
+ log accompanied with ROLLBACK TO SAVEPOINT statement. Since the real
+ write happens at the end of transaction releasing MDL on tables
+ mentioned in these events (i.e. acquired after savepoint and before
+ rollback ot it) can break replication, as concurrent DROP TABLES
+ statements will be able to drop these tables before events will get
+ into binary log,
+
+ For backward-compatibility reasons we always release MDL if binary
+ logging is off.
+ */
+ bool mdl_can_safely_rollback_to_savepoint=
+ (!(mysql_bin_log.is_open() && thd->variables.sql_log_bin) ||
+ ha_rollback_to_savepoint_can_release_mdl(thd));
+
if (ha_rollback_to_savepoint(thd, sv))
res= TRUE;
else if (((thd->variables.option_bits & OPTION_KEEP_LOG) ||
@@ -585,14 +611,7 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_STRING name)
thd->transaction.savepoints= sv;
- /*
- Release metadata locks that were acquired during this savepoint unit
- unless binlogging is on. Releasing locks with binlogging on can break
- replication as it allows other connections to drop these tables before
- rollback to savepoint is written to the binlog.
- */
- bool binlog_on= mysql_bin_log.is_open() && thd->variables.sql_log_bin;
- if (!res && !binlog_on)
+ if (!res && mdl_can_safely_rollback_to_savepoint)
thd->mdl_context.rollback_to_savepoint(sv->mdl_savepoint);
DBUG_RETURN(MY_TEST(res));