From 6aab1cececaf726c192048ae6d9e18247def696a Mon Sep 17 00:00:00 2001 From: Jon Olav Hauglid Date: Tue, 12 Jun 2012 15:04:57 +0200 Subject: [PATCH] Bug#13586591 RQG GRAMMAR CONF/ENGINES/ENGINE_STRESS.YY CRASHES INNODB | TRX_STATE_NOT_STARTED The problem was that if DELETE with subselect caused a deadlock inside InnoDB, this deadlock was not properly handled by the SQL layer. This meant that the SQL layer would try to unlock the row after InnoDB had rolled back the transaction. This caused an assertion inside InnoDB. This patch fixes the problem by checking for errors reported by SQL_SELECT::skip_record() and not calling unlock_row() if any errors have been reported. --- sql/sql_delete.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 4fd1815ad7f..1bbc9af0835 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -341,8 +341,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, break; } } - else + /* + Don't try unlocking the row if skip_record reported an error since in + this case the transaction might have been rolled back already. + */ + else if (!thd->is_error()) table->file->unlock_row(); // Row failed selection, release lock on it + else + break; } killed_status= thd->killed; if (killed_status != THD::NOT_KILLED || thd->is_error())