summaryrefslogtreecommitdiff
path: root/sql/transaction.cc
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@skysql.com>2014-05-21 11:09:55 -0400
committerNirbhay Choubey <nirbhay@skysql.com>2014-05-21 11:09:55 -0400
commit086af8367ed2499adae378638225ceb14c85f046 (patch)
tree953720d86a4decd67a24b560ffbe277900ff9609 /sql/transaction.cc
parent558995ad84ca1348dfe681a8d111650225fcc205 (diff)
parent1170a54060168d885cbf682836342d4fc4ccae1a (diff)
downloadmariadb-git-086af8367ed2499adae378638225ceb14c85f046.tar.gz
bzr merge -r4209 maria/10.0.
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 8770f729b88..72a8c47cdd8 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -616,6 +616,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) ||
@@ -627,14 +653,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));