summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-04-24 12:03:11 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-04-24 12:03:11 +0300
commitbfb0726fc24acb896e54bc7ef7536ad1aab9d574 (patch)
treea48e5d91d8427fefe2121128a4b3416d8d76e8a3 /storage
parent9dcfd6be94bd83d14fd48d69ce487eb0ea3fe37f (diff)
parentd5da8ae04d57556f517c0f03afeafe73c6cc75d1 (diff)
downloadmariadb-git-bfb0726fc24acb896e54bc7ef7536ad1aab9d574.tar.gz
Merge 5.5 into 10.1
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/dict/dict0dict.cc18
-rw-r--r--storage/innobase/include/trx0trx.h5
-rw-r--r--storage/innobase/include/trx0trx.ic3
-rw-r--r--storage/innobase/include/trx0types.h7
-rw-r--r--storage/innobase/lock/lock0lock.cc5
-rw-r--r--storage/innobase/trx/trx0roll.cc6
-rw-r--r--storage/innobase/trx/trx0trx.cc34
-rw-r--r--storage/xtradb/dict/dict0dict.cc18
-rw-r--r--storage/xtradb/include/trx0trx.h5
-rw-r--r--storage/xtradb/include/trx0trx.ic3
-rw-r--r--storage/xtradb/include/trx0types.h7
-rw-r--r--storage/xtradb/lock/lock0lock.cc5
-rw-r--r--storage/xtradb/trx/trx0roll.cc6
-rw-r--r--storage/xtradb/trx/trx0trx.cc34
14 files changed, 120 insertions, 36 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc
index 06c63fd7121..1e9d9f8d74e 100644
--- a/storage/innobase/dict/dict0dict.cc
+++ b/storage/innobase/dict/dict0dict.cc
@@ -4445,11 +4445,19 @@ dict_create_foreign_constraints_low(
}
orig = ptr;
- ptr = dict_accept(cs, ptr, "TABLE", &success);
-
- if (!success) {
-
- goto loop;
+ for (;;) {
+ ptr = dict_accept(cs, ptr, "TABLE", &success);
+ if (success) {
+ break;
+ }
+ ptr = dict_accept(cs, ptr, "ONLINE", &success);
+ if (success) {
+ continue;
+ }
+ ptr = dict_accept(cs, ptr, "IGNORE", &success);
+ if (!success) {
+ goto loop;
+ }
}
/* We are doing an ALTER TABLE: scan the table name we are altering */
diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h
index fe16b8272b8..165ebe82df8 100644
--- a/storage/innobase/include/trx0trx.h
+++ b/storage/innobase/include/trx0trx.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2018, MariaDB Corporation.
+Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -526,7 +526,7 @@ non-locking select */
ut_ad(!trx_is_autocommit_non_locking((t))); \
switch ((t)->state) { \
case TRX_STATE_PREPARED: \
- /* fall through */ \
+ case TRX_STATE_PREPARED_RECOVERED: \
case TRX_STATE_ACTIVE: \
case TRX_STATE_COMMITTED_IN_MEMORY: \
continue; \
@@ -719,6 +719,7 @@ struct trx_t{
TRX_STATE_NOT_STARTED
TRX_STATE_ACTIVE
TRX_STATE_PREPARED
+ TRX_STATE_PREPARED_RECOVERED (special case of TRX_STATE_PREPARED)
TRX_STATE_COMMITTED_IN_MEMORY (alias below COMMITTED)
Valid state transitions are:
diff --git a/storage/innobase/include/trx0trx.ic b/storage/innobase/include/trx0trx.ic
index fa30e6229a3..0011f2ca74b 100644
--- a/storage/innobase/include/trx0trx.ic
+++ b/storage/innobase/include/trx0trx.ic
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2016, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -49,6 +49,7 @@ trx_state_eq(
#ifdef UNIV_DEBUG
switch (trx->state) {
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
ut_ad(!trx_is_autocommit_non_locking(trx));
return(trx->state == state);
diff --git a/storage/innobase/include/trx0types.h b/storage/innobase/include/trx0types.h
index 7ca95131328..a0b398fffa1 100644
--- a/storage/innobase/include/trx0types.h
+++ b/storage/innobase/include/trx0types.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -48,7 +49,11 @@ enum trx_que_t {
enum trx_state_t {
TRX_STATE_NOT_STARTED,
TRX_STATE_ACTIVE,
- TRX_STATE_PREPARED, /* Support for 2PC/XA */
+ /** XA PREPARE has been executed; only XA COMMIT or XA ROLLBACK
+ are possible */
+ TRX_STATE_PREPARED,
+ /** XA PREPARE transaction that was returned to ha_recover() */
+ TRX_STATE_PREPARED_RECOVERED,
TRX_STATE_COMMITTED_IN_MEMORY
};
diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc
index f06fcd6c4d8..1ad5b9881b1 100644
--- a/storage/innobase/lock/lock0lock.cc
+++ b/storage/innobase/lock/lock0lock.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2018, MariaDB Corporation.
+Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -7908,7 +7908,8 @@ lock_trx_release_locks(
{
assert_trx_in_list(trx);
- if (trx_state_eq(trx, TRX_STATE_PREPARED)) {
+ if (trx_state_eq(trx, TRX_STATE_PREPARED)
+ || trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)) {
mutex_enter(&trx_sys->mutex);
ut_a(trx_sys->n_prepared_trx > 0);
trx_sys->n_prepared_trx--;
diff --git a/storage/innobase/trx/trx0roll.cc b/storage/innobase/trx/trx0roll.cc
index 3fd71aff23a..af17cfe6be5 100644
--- a/storage/innobase/trx/trx0roll.cc
+++ b/storage/innobase/trx/trx0roll.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2018, MariaDB Corporation.
+Copyright (c) 2016, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -203,6 +203,7 @@ trx_rollback_for_mysql(
return(trx_rollback_for_mysql_low(trx));
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
ut_ad(!trx_is_autocommit_non_locking(trx));
return(trx_rollback_for_mysql_low(trx));
@@ -255,6 +256,7 @@ trx_rollback_last_sql_stat_for_mysql(
return(err);
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
/* The statement rollback is only allowed on an ACTIVE
transaction, not a PREPARED or COMMITTED one. */
@@ -421,6 +423,7 @@ trx_rollback_to_savepoint_for_mysql(
return(trx_rollback_to_savepoint_for_mysql_low(
trx, savep, mysql_binlog_cache_pos));
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
/* The savepoint rollback is only allowed on an ACTIVE
transaction, not a PREPARED or COMMITTED one. */
@@ -710,6 +713,7 @@ fake_prepared:
}
return(FALSE);
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
goto func_exit;
case TRX_STATE_NOT_STARTED:
break;
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index f36aabba8b4..4175777cc61 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2018, MariaDB Corporation.
+Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -314,6 +314,7 @@ trx_free_prepared(
trx_t* trx) /*!< in, own: trx object */
{
ut_a(trx_state_eq(trx, TRX_STATE_PREPARED)
+ || trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)
|| (trx->is_recovered
&& (trx_state_eq(trx, TRX_STATE_ACTIVE)
|| trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY))
@@ -568,8 +569,7 @@ trx_resurrect_insert(
/* trx_start_low() is not called with resurrect, so need to initialize
start time here.*/
- if (trx->state == TRX_STATE_ACTIVE
- || trx->state == TRX_STATE_PREPARED) {
+ if (trx->state != TRX_STATE_COMMITTED_IN_MEMORY) {
trx->start_time = ut_time();
}
@@ -1536,6 +1536,7 @@ trx_commit_or_rollback_prepare(
/* fall through */
case TRX_STATE_ACTIVE:
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
/* If the trx is in a lock wait state, moves the waiting
query thread to the suspended state */
@@ -1661,6 +1662,7 @@ trx_commit_for_mysql(
/* fall through */
case TRX_STATE_ACTIVE:
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
trx->op_info = "committing";
trx_commit(trx);
MONITOR_DEC(MONITOR_TRX_ACTIVE);
@@ -1706,6 +1708,7 @@ trx_mark_sql_stat_end(
switch (trx->state) {
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
break;
case TRX_STATE_NOT_STARTED:
@@ -1764,6 +1767,7 @@ trx_print_low(
(ulong) difftime(time(NULL), trx->start_time));
goto state_ok;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
fprintf(f, ", ACTIVE (PREPARED) %lu sec",
(ulong) difftime(time(NULL), trx->start_time));
goto state_ok;
@@ -1908,6 +1912,7 @@ wsrep_trx_print_locking(
(ulong) difftime(time(NULL), trx->start_time));
goto state_ok;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
fprintf(f, ", ACTIVE (PREPARED) %lu sec",
(ulong) difftime(time(NULL), trx->start_time));
goto state_ok;
@@ -2035,6 +2040,7 @@ trx_assert_started(
switch (trx->state) {
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
return(TRUE);
case TRX_STATE_ACTIVE:
@@ -2200,7 +2206,7 @@ trx_recover_for_mysql(
XID* xid_list, /*!< in/out: prepared transactions */
ulint len) /*!< in: number of slots in xid_list */
{
- const trx_t* trx;
+ trx_t* trx;
ulint count = 0;
ut_ad(xid_list);
@@ -2222,6 +2228,7 @@ trx_recover_for_mysql(
trx_sys->mutex. It may change to PREPARED, but not if
trx->is_recovered. It may also change to COMMITTED. */
if (trx_state_eq(trx, TRX_STATE_PREPARED)) {
+ trx->state = TRX_STATE_PREPARED_RECOVERED;
xid_list[count] = trx->xid;
if (count == 0) {
@@ -2246,11 +2253,22 @@ trx_recover_for_mysql(
count++;
if (count == len) {
- break;
+ goto partial;
}
}
}
+ /* After returning the full list, reset the state, because
+ there will be a second call to recover the transactions. */
+ for (trx = UT_LIST_GET_FIRST(trx_sys->rw_trx_list);
+ trx != NULL;
+ trx = UT_LIST_GET_NEXT(trx_list, trx)) {
+ if (trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)) {
+ trx->state = TRX_STATE_PREPARED;
+ }
+ }
+
+partial:
mutex_exit(&trx_sys->mutex);
if (count > 0){
@@ -2293,7 +2311,8 @@ trx_get_trx_by_xid_low(
the same */
if (trx->is_recovered
- && trx_state_eq(trx, TRX_STATE_PREPARED)
+ && (trx_state_eq(trx, TRX_STATE_PREPARED)
+ || trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED))
&& !trx->xid.is_null()
&& xid->gtrid_length == trx->xid.gtrid_length
&& xid->bqual_length == trx->xid.bqual_length
@@ -2373,6 +2392,7 @@ trx_start_if_not_started_xa_low(
case TRX_STATE_ACTIVE:
return;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
break;
}
@@ -2395,6 +2415,7 @@ trx_start_if_not_started_low(
case TRX_STATE_ACTIVE:
return;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
break;
}
@@ -2436,6 +2457,7 @@ trx_start_for_ddl_low(
ut_ad(trx->will_lock > 0);
return;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
break;
}
diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc
index b587aec5370..344f58decd0 100644
--- a/storage/xtradb/dict/dict0dict.cc
+++ b/storage/xtradb/dict/dict0dict.cc
@@ -4454,11 +4454,19 @@ dict_create_foreign_constraints_low(
}
orig = ptr;
- ptr = dict_accept(cs, ptr, "TABLE", &success);
-
- if (!success) {
-
- goto loop;
+ for (;;) {
+ ptr = dict_accept(cs, ptr, "TABLE", &success);
+ if (success) {
+ break;
+ }
+ ptr = dict_accept(cs, ptr, "ONLINE", &success);
+ if (success) {
+ continue;
+ }
+ ptr = dict_accept(cs, ptr, "IGNORE", &success);
+ if (!success) {
+ goto loop;
+ }
}
/* We are doing an ALTER TABLE: scan the table name we are altering */
diff --git a/storage/xtradb/include/trx0trx.h b/storage/xtradb/include/trx0trx.h
index 77afde4c35c..b3a513b9b91 100644
--- a/storage/xtradb/include/trx0trx.h
+++ b/storage/xtradb/include/trx0trx.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2018, MariaDB Corporation.
+Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -575,7 +575,7 @@ non-locking select */
ut_ad(!trx_is_autocommit_non_locking((t))); \
switch ((t)->state) { \
case TRX_STATE_PREPARED: \
- /* fall through */ \
+ case TRX_STATE_PREPARED_RECOVERED: \
case TRX_STATE_ACTIVE: \
case TRX_STATE_COMMITTED_IN_MEMORY: \
continue; \
@@ -768,6 +768,7 @@ struct trx_t{
TRX_STATE_NOT_STARTED
TRX_STATE_ACTIVE
TRX_STATE_PREPARED
+ TRX_STATE_PREPARED_RECOVERED (special case of TRX_STATE_PREPARED)
TRX_STATE_COMMITTED_IN_MEMORY (alias below COMMITTED)
Valid state transitions are:
diff --git a/storage/xtradb/include/trx0trx.ic b/storage/xtradb/include/trx0trx.ic
index eb7d62d9cad..6b8078a55e8 100644
--- a/storage/xtradb/include/trx0trx.ic
+++ b/storage/xtradb/include/trx0trx.ic
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2016, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -49,6 +49,7 @@ trx_state_eq(
#ifdef UNIV_DEBUG
switch (trx->state) {
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
ut_ad(!trx_is_autocommit_non_locking(trx));
return(trx->state == state);
diff --git a/storage/xtradb/include/trx0types.h b/storage/xtradb/include/trx0types.h
index 7ca95131328..a0b398fffa1 100644
--- a/storage/xtradb/include/trx0types.h
+++ b/storage/xtradb/include/trx0types.h
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -48,7 +49,11 @@ enum trx_que_t {
enum trx_state_t {
TRX_STATE_NOT_STARTED,
TRX_STATE_ACTIVE,
- TRX_STATE_PREPARED, /* Support for 2PC/XA */
+ /** XA PREPARE has been executed; only XA COMMIT or XA ROLLBACK
+ are possible */
+ TRX_STATE_PREPARED,
+ /** XA PREPARE transaction that was returned to ha_recover() */
+ TRX_STATE_PREPARED_RECOVERED,
TRX_STATE_COMMITTED_IN_MEMORY
};
diff --git a/storage/xtradb/lock/lock0lock.cc b/storage/xtradb/lock/lock0lock.cc
index 9daa2cc906f..9c86abf7172 100644
--- a/storage/xtradb/lock/lock0lock.cc
+++ b/storage/xtradb/lock/lock0lock.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2014, 2018, MariaDB Corporation.
+Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -8010,7 +8010,8 @@ lock_trx_release_locks(
{
assert_trx_in_list(trx);
- if (trx_state_eq(trx, TRX_STATE_PREPARED)) {
+ if (trx_state_eq(trx, TRX_STATE_PREPARED)
+ || trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)) {
mutex_enter(&trx_sys->mutex);
ut_a(trx_sys->n_prepared_trx > 0);
trx_sys->n_prepared_trx--;
diff --git a/storage/xtradb/trx/trx0roll.cc b/storage/xtradb/trx/trx0roll.cc
index 56b7120fa34..6f393511611 100644
--- a/storage/xtradb/trx/trx0roll.cc
+++ b/storage/xtradb/trx/trx0roll.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2018, MariaDB Corporation.
+Copyright (c) 2016, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -208,6 +208,7 @@ trx_rollback_for_mysql(
return(trx_rollback_for_mysql_low(trx));
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
ut_ad(!trx_is_autocommit_non_locking(trx));
return(trx_rollback_for_mysql_low(trx));
@@ -260,6 +261,7 @@ trx_rollback_last_sql_stat_for_mysql(
return(err);
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
/* The statement rollback is only allowed on an ACTIVE
transaction, not a PREPARED or COMMITTED one. */
@@ -433,6 +435,7 @@ trx_rollback_to_savepoint_for_mysql(
return(trx_rollback_to_savepoint_for_mysql_low(
trx, savep, mysql_binlog_cache_pos));
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
/* The savepoint rollback is only allowed on an ACTIVE
transaction, not a PREPARED or COMMITTED one. */
@@ -722,6 +725,7 @@ fake_prepared:
}
return(FALSE);
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
goto func_exit;
case TRX_STATE_NOT_STARTED:
break;
diff --git a/storage/xtradb/trx/trx0trx.cc b/storage/xtradb/trx/trx0trx.cc
index 17cba81daf3..1044a9321a0 100644
--- a/storage/xtradb/trx/trx0trx.cc
+++ b/storage/xtradb/trx/trx0trx.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2015, 2018, MariaDB Corporation.
+Copyright (c) 2015, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -480,6 +480,7 @@ trx_free_prepared(
trx_t* trx) /*!< in, own: trx object */
{
ut_a(trx_state_eq(trx, TRX_STATE_PREPARED)
+ || trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)
|| (trx->is_recovered
&& (trx_state_eq(trx, TRX_STATE_ACTIVE)
|| trx_state_eq(trx, TRX_STATE_COMMITTED_IN_MEMORY))
@@ -747,8 +748,7 @@ trx_resurrect_insert(
/* trx_start_low() is not called with resurrect, so need to initialize
start time here.*/
- if (trx->state == TRX_STATE_ACTIVE
- || trx->state == TRX_STATE_PREPARED) {
+ if (trx->state != TRX_STATE_COMMITTED_IN_MEMORY) {
trx->start_time = ut_time();
}
@@ -1790,6 +1790,7 @@ trx_commit_or_rollback_prepare(
/* fall through */
case TRX_STATE_ACTIVE:
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
/* If the trx is in a lock wait state, moves the waiting
query thread to the suspended state */
@@ -1927,6 +1928,7 @@ trx_commit_for_mysql(
/* fall through */
case TRX_STATE_ACTIVE:
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
trx->op_info = "committing";
trx_commit(trx);
MONITOR_DEC(MONITOR_TRX_ACTIVE);
@@ -1983,6 +1985,7 @@ trx_mark_sql_stat_end(
switch (trx->state) {
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
break;
case TRX_STATE_NOT_STARTED:
@@ -2041,6 +2044,7 @@ trx_print_low(
(ulong) difftime(time(NULL), trx->start_time));
goto state_ok;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
fprintf(f, ", ACTIVE (PREPARED) %lu sec",
(ulong) difftime(time(NULL), trx->start_time));
goto state_ok;
@@ -2185,6 +2189,7 @@ wsrep_trx_print_locking(
(ulong) difftime(time(NULL), trx->start_time));
goto state_ok;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
fprintf(f, ", ACTIVE (PREPARED) %lu sec",
(ulong) difftime(time(NULL), trx->start_time));
goto state_ok;
@@ -2313,6 +2318,7 @@ trx_assert_started(
switch (trx->state) {
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
return(TRUE);
case TRX_STATE_ACTIVE:
@@ -2478,7 +2484,7 @@ trx_recover_for_mysql(
XID* xid_list, /*!< in/out: prepared transactions */
ulint len) /*!< in: number of slots in xid_list */
{
- const trx_t* trx;
+ trx_t* trx;
ulint count = 0;
ut_ad(xid_list);
@@ -2500,6 +2506,7 @@ trx_recover_for_mysql(
trx_sys->mutex. It may change to PREPARED, but not if
trx->is_recovered. It may also change to COMMITTED. */
if (trx_state_eq(trx, TRX_STATE_PREPARED)) {
+ trx->state = TRX_STATE_PREPARED_RECOVERED;
xid_list[count] = trx->xid;
if (count == 0) {
@@ -2524,11 +2531,22 @@ trx_recover_for_mysql(
count++;
if (count == len) {
- break;
+ goto partial;
}
}
}
+ /* After returning the full list, reset the state, because
+ there will be a second call to recover the transactions. */
+ for (trx = UT_LIST_GET_FIRST(trx_sys->rw_trx_list);
+ trx != NULL;
+ trx = UT_LIST_GET_NEXT(trx_list, trx)) {
+ if (trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED)) {
+ trx->state = TRX_STATE_PREPARED;
+ }
+ }
+
+partial:
mutex_exit(&trx_sys->mutex);
if (count > 0){
@@ -2571,7 +2589,8 @@ trx_get_trx_by_xid_low(
the same */
if (trx->is_recovered
- && trx_state_eq(trx, TRX_STATE_PREPARED)
+ && (trx_state_eq(trx, TRX_STATE_PREPARED)
+ || trx_state_eq(trx, TRX_STATE_PREPARED_RECOVERED))
&& !trx->xid.is_null()
&& xid->gtrid_length == trx->xid.gtrid_length
&& xid->bqual_length == trx->xid.bqual_length
@@ -2651,6 +2670,7 @@ trx_start_if_not_started_xa_low(
case TRX_STATE_ACTIVE:
return;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
break;
}
@@ -2677,6 +2697,7 @@ trx_start_if_not_started_low(
case TRX_STATE_ACTIVE:
return;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
break;
}
@@ -2722,6 +2743,7 @@ trx_start_for_ddl_low(
ut_ad(trx->will_lock > 0);
return;
case TRX_STATE_PREPARED:
+ case TRX_STATE_PREPARED_RECOVERED:
case TRX_STATE_COMMITTED_IN_MEMORY:
break;
}