diff options
Diffstat (limited to 'storage/xtradb/trx/trx0trx.cc')
-rw-r--r-- | storage/xtradb/trx/trx0trx.cc | 34 |
1 files changed, 28 insertions, 6 deletions
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; } |