summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@oracle.com>2011-11-10 12:49:31 +0200
committerMarko Mäkelä <marko.makela@oracle.com>2011-11-10 12:49:31 +0200
commitd7946a908f9ad760e1b7a21aa330b71615ce4702 (patch)
treea1e5e010bd0a3644af8424d22ce41dcb33d26be1 /sql/sql_insert.cc
parentf62a233a4da6d83546076a2cec6dd08398347542 (diff)
downloadmariadb-git-d7946a908f9ad760e1b7a21aa330b71615ce4702.tar.gz
Bug#11759688 52020: InnoDB can still deadlock on just INSERT...ON DUPLICATE KEY
a.k.a. Bug#7975 deadlock without any locking, simple select and update Bug#7975 was reintroduced when the storage engine API was made pluggable in MySQL 5.1. Instead of looking at thd->lex directly, we rely on handler::extra(). But, we were looking at the wrong extra() flag, and we were ignoring the TRX_DUP_REPLACE flag in places where we should obey it. innodb_replace.test: Add tests for hopefully all affected statement types, so that bug should never ever resurface. This kind of tests should have been added when fixing Bug#7975 in MySQL 5.0.3 in the first place. rb:806 approved by Sunny Bains
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index e176e5c9b6d..4cd456829ba 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -63,6 +63,8 @@
#include "slave.h"
#include "rpl_mi.h"
+#include "debug_sync.h"
+
#ifndef EMBEDDED_LIBRARY
static bool delayed_get_table(THD *thd, TABLE_LIST *table_list);
static int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic,
@@ -1411,6 +1413,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
error= HA_ERR_FOUND_DUPP_KEY; /* Database can't find key */
goto err;
}
+ DEBUG_SYNC(thd, "write_row_replace");
+
/* Read all columns for the row we are going to replace */
table->use_all_columns();
/*
@@ -1604,6 +1608,7 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
}
else if ((error=table->file->ha_write_row(table->record[0])))
{
+ DEBUG_SYNC(thd, "write_row_noreplace");
if (!info->ignore ||
table->file->is_fatal_error(error, HA_CHECK_DUP))
goto err;