summaryrefslogtreecommitdiff
path: root/sql/transaction.cc
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2010-06-25 09:32:24 +0200
committerJon Olav Hauglid <jon.hauglid@sun.com>2010-06-25 09:32:24 +0200
commit47edc4cade1dc4eb37bbe11db40f2712469d01cb (patch)
tree58081464a1f0e5ba734a5431c35b32f2af193ede /sql/transaction.cc
parenta5d9e0e0c4dd294f31a2a3efe744e37658bfdde2 (diff)
downloadmariadb-git-47edc4cade1dc4eb37bbe11db40f2712469d01cb.tar.gz
Bug #50124 Rpl failure on DROP table with concurrent txn/non-txn
DML flow and SAVEPOINT The problem was that replication could break if a transaction involving both transactional and non-transactional tables was rolled back to a savepoint. It broke if a concurrent connection tried to drop a transactional table which was locked after the savepoint was set. This DROP TABLE completed when ROLLBACK TO SAVEPOINT was executed as the lock on the table was dropped by the transaction. When the slave later tried to apply the binlog, it would fail as the table would already have been dropped. The reason for the problem is that transactions involving both transactional and non-transactional tables are written fully to the binlog during ROLLBACK TO SAVEPOINT. At the same time, metadata locks acquired after a savepoint, were released during ROLLBACK TO SAVEPOINT. This allowed a second connection to drop a table only used between SAVEPOINT and ROLLBACK TO SAVEPOINT. Which caused the transaction binlog to refer to a non-existing table when it was written during ROLLBACK TO SAVEPOINT. This patch fixes the problem by not releasing metadata locks when ROLLBACK TO SAVEPOINT is executed if binlogging is enabled.
Diffstat (limited to 'sql/transaction.cc')
-rw-r--r--sql/transaction.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 78551d6fcf7..f6786f20dcf 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -419,9 +419,13 @@ bool trans_rollback_to_savepoint(THD *thd, LEX_STRING name)
thd->transaction.savepoints= sv;
/*
- Release metadata locks that were acquired during this savepoint unit.
+ 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.
*/
- if (!res)
+ bool binlog_on= mysql_bin_log.is_open() && thd->variables.sql_log_bin;
+ if (!res && !binlog_on)
thd->mdl_context.rollback_to_savepoint(sv->mdl_savepoint);
DBUG_RETURN(test(res));