Commit 54b26b49 authored by Nirbhay Choubey's avatar Nirbhay Choubey

MDEV-7129 : Galera duplicate error on autoincrement field primary key

Merged fix for https://github.com/codership/mysql-wsrep/issues/18.
parent 455f77bd
...@@ -490,7 +490,8 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all) ...@@ -490,7 +490,8 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all)
case WSREP_BF_ABORT: case WSREP_BF_ABORT:
DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED); DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED);
case WSREP_TRX_FAIL: case WSREP_TRX_FAIL:
WSREP_DEBUG("commit failed for reason: %d", rcode); WSREP_DEBUG("commit failed for reason: %d %lu %s", rcode, thd->thread_id,
thd->query());
DBUG_PRINT("wsrep", ("replicating commit fail")); DBUG_PRINT("wsrep", ("replicating commit fail"));
thd->wsrep_query_state= QUERY_EXEC; thd->wsrep_query_state= QUERY_EXEC;
......
...@@ -7623,6 +7623,14 @@ ha_innobase::write_row( ...@@ -7623,6 +7623,14 @@ ha_innobase::write_row(
#ifdef WITH_WSREP #ifdef WITH_WSREP
/* workaround for LP bug #355000, retrying the insert */ /* workaround for LP bug #355000, retrying the insert */
case SQLCOM_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) && if (wsrep_on(current_thd) &&
auto_inc_inserted && auto_inc_inserted &&
wsrep_drupal_282555_workaround && wsrep_drupal_282555_workaround &&
...@@ -7638,8 +7646,7 @@ ha_innobase::write_row( ...@@ -7638,8 +7646,7 @@ ha_innobase::write_row(
error= DB_SUCCESS; error= DB_SUCCESS;
wsrep_thd_set_conflict_state( wsrep_thd_set_conflict_state(
current_thd, MUST_ABORT); current_thd, MUST_ABORT);
innobase_srv_conc_exit_innodb( innobase_srv_conc_exit_innodb(prebuilt->trx);
prebuilt->trx);
/* jump straight to func exit over /* jump straight to func exit over
* later wsrep hooks */ * later wsrep hooks */
goto func_exit; goto func_exit;
...@@ -9700,10 +9707,10 @@ wsrep_append_key( ...@@ -9700,10 +9707,10 @@ wsrep_append_key(
DBUG_ENTER("wsrep_append_key"); DBUG_ENTER("wsrep_append_key");
bool const copy = true; bool const copy = true;
#ifdef WSREP_DEBUG_PRINT #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", (shared) ? "Shared" : "Exclusive",
wsrep_thd_thread_id(thd), (long long)trx->id, key_len, wsrep_thd_thread_id(thd), (long long)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++) { for (int i=0; i<key_len; i++) {
fprintf(stderr, "%hhX, ", key[i]); fprintf(stderr, "%hhX, ", key[i]);
} }
...@@ -14746,7 +14753,20 @@ ha_innobase::get_auto_increment( ...@@ -14746,7 +14753,20 @@ ha_innobase::get_auto_increment(
next value in the series. */ next value in the series. */
if (prebuilt->autoinc_increment > increment) { 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; current = autoinc - prebuilt->autoinc_increment;
#ifdef WITH_WSREP
}
#endif /* WITH_WSREP */
current = innobase_next_autoinc( current = innobase_next_autoinc(
current, 1, increment, 1, col_max_value); current, 1, increment, 1, col_max_value);
......
...@@ -8207,6 +8207,14 @@ ha_innobase::write_row( ...@@ -8207,6 +8207,14 @@ ha_innobase::write_row(
#ifdef WITH_WSREP #ifdef WITH_WSREP
/* workaround for LP bug #355000, retrying the insert */ /* workaround for LP bug #355000, retrying the insert */
case SQLCOM_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) && if (wsrep_on(current_thd) &&
auto_inc_inserted && auto_inc_inserted &&
wsrep_drupal_282555_workaround && wsrep_drupal_282555_workaround &&
...@@ -10331,10 +10339,10 @@ wsrep_append_key( ...@@ -10331,10 +10339,10 @@ wsrep_append_key(
DBUG_ENTER("wsrep_append_key"); DBUG_ENTER("wsrep_append_key");
bool const copy = true; bool const copy = true;
#ifdef WSREP_DEBUG_PRINT #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", (shared) ? "Shared" : "Exclusive",
wsrep_thd_thread_id(thd), (long long)trx->id, key_len, wsrep_thd_thread_id(thd), (long long)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++) { for (int i=0; i<key_len; i++) {
fprintf(stderr, "%hhX, ", key[i]); fprintf(stderr, "%hhX, ", key[i]);
} }
...@@ -15445,7 +15453,20 @@ ha_innobase::get_auto_increment( ...@@ -15445,7 +15453,20 @@ ha_innobase::get_auto_increment(
next value in the series. */ next value in the series. */
if (prebuilt->autoinc_increment > increment) { 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; current = autoinc - prebuilt->autoinc_increment;
#ifdef WITH_WSREP
}
#endif /* WITH_WSREP */
current = innobase_next_autoinc( current = innobase_next_autoinc(
current, 1, increment, 1, col_max_value); current, 1, increment, 1, col_max_value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment