summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2015-01-07 17:22:53 -0500
committerNirbhay Choubey <nirbhay@mariadb.com>2015-01-07 17:22:53 -0500
commit743a28ea5714459fe09782dab9a4a7a0b0ff6673 (patch)
treebcb88d3f7370fe7a47acd7ab7aa8a4b05ff84c15 /storage
parent952b575272d47a48a1c55e83d3ff9a548857e564 (diff)
downloadmariadb-git-743a28ea5714459fe09782dab9a4a7a0b0ff6673.tar.gz
MDEV-7129 : Galera duplicate error on autoincrement field primary key
Merged fix for https://github.com/codership/mysql-wsrep/issues/18.
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/handler/ha_innodb.cc25
-rw-r--r--storage/xtradb/handler/ha_innodb.cc25
2 files changed, 46 insertions, 4 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index f509238c1e9..8b30334d198 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -5901,6 +5901,14 @@ no_commit:
#ifdef WITH_WSREP
/* workaround for LP bug #355000, retrying the insert */
case SQLCOM_INSERT:
+
+ WSREP_DEBUG("DUPKEY error for autoinc\n"
+ "THD %ld, value %llu, off %llu inc %llu",
+ wsrep_thd_thread_id(current_thd),
+ auto_inc,
+ prebuilt->autoinc_offset,
+ prebuilt->autoinc_increment);
+
if (wsrep_on(current_thd) &&
auto_inc_inserted &&
wsrep_drupal_282555_workaround &&
@@ -7400,10 +7408,10 @@ wsrep_append_key(
DBUG_ENTER("wsrep_append_key");
bool const copy = true;
#ifdef WSREP_DEBUG_PRINT
- fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s ",
+ fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s\n Query: %s ",
(shared) ? "Shared" : "Exclusive",
wsrep_thd_thread_id(thd), trx->id, key_len,
- table_share->table_name.str);
+ table_share->table_name.str, wsrep_thd_query(thd));
for (int i=0; i<key_len; i++) {
fprintf(stderr, "%hhX, ", key[i]);
}
@@ -11473,7 +11481,20 @@ ha_innobase::get_auto_increment(
next value in the series. */
if (prebuilt->autoinc_increment > increment) {
+#ifdef WITH_WSREP
+ WSREP_DEBUG("autoinc decrease: %llu -> %llu\n"
+ "THD: %ld, current: %llu, autoinc: %llu",
+ prebuilt->autoinc_increment,
+ increment,
+ wsrep_thd_thread_id(ha_thd()),
+ current, autoinc);
+ if (!wsrep_on(ha_thd()))
+ {
+#endif /* WITH_WSREP */
current = autoinc - prebuilt->autoinc_increment;
+#ifdef WITH_WSREP
+ }
+#endif /* WITH_WSREP */
current = innobase_next_autoinc(
current, 1, increment, 1, col_max_value);
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 4136f8d50a6..8c881a07123 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -6871,6 +6871,14 @@ no_commit:
#ifdef WITH_WSREP
/* workaround for LP bug #355000, retrying the insert */
case SQLCOM_INSERT:
+
+ WSREP_DEBUG("DUPKEY error for autoinc\n"
+ "THD %ld, value %llu, off %llu inc %llu",
+ wsrep_thd_thread_id(current_thd),
+ auto_inc,
+ prebuilt->autoinc_offset,
+ prebuilt->autoinc_increment);
+
if (wsrep_on(current_thd) &&
auto_inc_inserted &&
wsrep_drupal_282555_workaround &&
@@ -8443,10 +8451,10 @@ wsrep_append_key(
DBUG_ENTER("wsrep_append_key");
bool const copy = true;
#ifdef WSREP_DEBUG_PRINT
- fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s ",
+ fprintf(stderr, "%s conn %ld, trx %llu, keylen %d, table %s\n Query: %s ",
(shared) ? "Shared" : "Exclusive",
wsrep_thd_thread_id(thd), trx->id, key_len,
- table_share->table_name.str);
+ table_share->table_name.str, wsrep_thd_query(thd));
for (int i=0; i<key_len; i++) {
fprintf(stderr, "%hhX, ", key[i]);
}
@@ -12591,7 +12599,20 @@ ha_innobase::get_auto_increment(
next value in the series. */
if (prebuilt->autoinc_increment > increment) {
+#ifdef WITH_WSREP
+ WSREP_DEBUG("autoinc decrease: %llu -> %llu\n"
+ "THD: %ld, current: %llu, autoinc: %llu",
+ prebuilt->autoinc_increment,
+ increment,
+ wsrep_thd_thread_id(ha_thd()),
+ current, autoinc);
+ if (!wsrep_on(ha_thd()))
+ {
+#endif /* WITH_WSREP */
current = autoinc - prebuilt->autoinc_increment;
+#ifdef WITH_WSREP
+ }
+#endif /* WITH_WSREP */
current = innobase_next_autoinc(
current, 1, increment, 1, col_max_value);