From fb5d9a82a783f8a5046daeb1b90884d133b803a5 Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Mon, 26 Aug 2013 14:43:12 +0400 Subject: Fix for bug #17356954 "CANNOT USE SAVEPOINTS AFTER ER_LOCK_DEADLOCK OR ER_LOCK_WAIT_TIMEOUT". The problem was that after changes caused by fix bug 14188793 "DEADLOCK CAUSED BY ALTER TABLE DOEN'T CLEAR STATUS OF ROLLBACKED TRANSACTION"/ bug 17054007 "TRANSACTION IS NOT FULLY ROLLED BACK IN CASE OF INNODB DEADLOCK implicit rollback of transaction which occurred on ER_LOCK_DEADLOCK (and ER_LOCK_WAIT_TIMEOUT if innodb_rollback_on_timeout option was set) didn't start new transaction in @@autocommit=1 mode. Such behavior although consistent with behavior of explicit ROLLBACK has broken expectations of users and backward compatibility assumptions. This patch fixes problem by reverting to starting new transaction in 5.5/5.6. The plan is to keep new behavior in trunk so the code change from this patch is to be null-merged there. --- sql/transaction.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sql/transaction.cc') diff --git a/sql/transaction.cc b/sql/transaction.cc index 4fd6af39135..ae38e920a1d 100644 --- a/sql/transaction.cc +++ b/sql/transaction.cc @@ -298,7 +298,12 @@ bool trans_rollback_implicit(THD *thd) thd->server_status&= ~SERVER_STATUS_IN_TRANS; DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS")); res= ha_rollback_trans(thd, true); - thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG); + /* + We don't reset OPTION_BEGIN flag below to simulate implicit start + of new transacton in @@autocommit=1 mode. This is necessary to + preserve backward compatibility. + */ + thd->variables.option_bits&= ~(OPTION_KEEP_LOG); thd->transaction.all.modified_non_trans_table= false; /* Rollback should clear transaction_rollback_request flag. */ -- cgit v1.2.1