Commit 76ec37f5 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-14705: Do not rollback on InnoDB shutdown

row_undo_step(): If fast shutdown has been requested, abort the
rollback of any non-DDL transactions. Starting with MDEV-12323,
we aborted the rollback of recovered transactions. These
transactions would be rolled back on subsequent server startup.

trx_roll_report_progress(): Renamed from trx_roll_must_shutdown(),
now that the shutdown check has been moved to the only caller.
parent 3a6283cb
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -105,11 +105,8 @@ trx_undo_rec_release( ...@@ -105,11 +105,8 @@ trx_undo_rec_release(
/*=================*/ /*=================*/
trx_t* trx, /*!< in/out: transaction */ trx_t* trx, /*!< in/out: transaction */
undo_no_t undo_no);/*!< in: undo number */ undo_no_t undo_no);/*!< in: undo number */
/** Report progress when rolling back a row of a recovered transaction. /** Report progress when rolling back a row of a recovered transaction. */
@return whether the rollback should be aborted due to pending shutdown */ UNIV_INTERN void trx_roll_report_progress();
UNIV_INTERN
bool
trx_roll_must_shutdown();
/*******************************************************************//** /*******************************************************************//**
Rollback or clean up any incomplete transactions which were Rollback or clean up any incomplete transactions which were
encountered in crash recovery. If the transaction already was encountered in crash recovery. If the transaction already was
......
...@@ -45,6 +45,7 @@ Created 1/8/1997 Heikki Tuuri ...@@ -45,6 +45,7 @@ Created 1/8/1997 Heikki Tuuri
#include "row0upd.h" #include "row0upd.h"
#include "row0mysql.h" #include "row0mysql.h"
#include "srv0srv.h" #include "srv0srv.h"
#include "srv0start.h"
/* How to undo row operations? /* How to undo row operations?
(1) For an insert, we have stored a prefix of the clustered index record (1) For an insert, we have stored a prefix of the clustered index record
...@@ -349,13 +350,17 @@ row_undo_step( ...@@ -349,13 +350,17 @@ row_undo_step(
ut_ad(que_node_get_type(node) == QUE_NODE_UNDO); ut_ad(que_node_get_type(node) == QUE_NODE_UNDO);
if (UNIV_UNLIKELY(trx == trx_roll_crash_recv_trx) if (UNIV_UNLIKELY(trx_get_dict_operation(trx) == TRX_DICT_OP_NONE
&& trx_roll_must_shutdown()) { && !srv_undo_sources && srv_fast_shutdown)) {
/* Shutdown has been initiated. */ /* Shutdown has been initiated. */
trx->error_state = DB_INTERRUPTED; trx->error_state = DB_INTERRUPTED;
return(NULL); return(NULL);
} }
if (UNIV_UNLIKELY(trx == trx_roll_crash_recv_trx)) {
trx_roll_report_progress();
}
err = row_undo(node, thr); err = row_undo(node, thr);
trx->error_state = err; trx->error_state = err;
......
...@@ -719,21 +719,9 @@ trx_rollback_resurrected( ...@@ -719,21 +719,9 @@ trx_rollback_resurrected(
goto func_exit; goto func_exit;
} }
/** Report progress when rolling back a row of a recovered transaction. /** Report progress when rolling back a row of a recovered transaction. */
@return whether the rollback should be aborted due to pending shutdown */ UNIV_INTERN void trx_roll_report_progress()
UNIV_INTERN
bool
trx_roll_must_shutdown()
{ {
const trx_t* trx = trx_roll_crash_recv_trx;
ut_ad(trx);
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
if (trx_get_dict_operation(trx) == TRX_DICT_OP_NONE
&& !srv_undo_sources && srv_fast_shutdown) {
return true;
}
ib_time_t time = ut_time(); ib_time_t time = ut_time();
mutex_enter(&trx_sys->mutex); mutex_enter(&trx_sys->mutex);
mutex_enter(&recv_sys->mutex); mutex_enter(&recv_sys->mutex);
...@@ -761,7 +749,6 @@ trx_roll_must_shutdown() ...@@ -761,7 +749,6 @@ trx_roll_must_shutdown()
mutex_exit(&recv_sys->mutex); mutex_exit(&recv_sys->mutex);
mutex_exit(&trx_sys->mutex); mutex_exit(&trx_sys->mutex);
return false;
} }
/*******************************************************************//** /*******************************************************************//**
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
...@@ -106,11 +106,8 @@ trx_undo_rec_release( ...@@ -106,11 +106,8 @@ trx_undo_rec_release(
/*=================*/ /*=================*/
trx_t* trx, /*!< in/out: transaction */ trx_t* trx, /*!< in/out: transaction */
undo_no_t undo_no);/*!< in: undo number */ undo_no_t undo_no);/*!< in: undo number */
/** Report progress when rolling back a row of a recovered transaction. /** Report progress when rolling back a row of a recovered transaction. */
@return whether the rollback should be aborted due to pending shutdown */ UNIV_INTERN void trx_roll_report_progress();
UNIV_INTERN
bool
trx_roll_must_shutdown();
/*******************************************************************//** /*******************************************************************//**
Rollback or clean up any incomplete transactions which were Rollback or clean up any incomplete transactions which were
encountered in crash recovery. If the transaction already was encountered in crash recovery. If the transaction already was
......
...@@ -45,6 +45,7 @@ Created 1/8/1997 Heikki Tuuri ...@@ -45,6 +45,7 @@ Created 1/8/1997 Heikki Tuuri
#include "row0upd.h" #include "row0upd.h"
#include "row0mysql.h" #include "row0mysql.h"
#include "srv0srv.h" #include "srv0srv.h"
#include "srv0start.h"
/* How to undo row operations? /* How to undo row operations?
(1) For an insert, we have stored a prefix of the clustered index record (1) For an insert, we have stored a prefix of the clustered index record
...@@ -349,13 +350,17 @@ row_undo_step( ...@@ -349,13 +350,17 @@ row_undo_step(
ut_ad(que_node_get_type(node) == QUE_NODE_UNDO); ut_ad(que_node_get_type(node) == QUE_NODE_UNDO);
if (UNIV_UNLIKELY(trx == trx_roll_crash_recv_trx) if (UNIV_UNLIKELY(trx_get_dict_operation(trx) == TRX_DICT_OP_NONE
&& trx_roll_must_shutdown()) { && !srv_undo_sources && srv_fast_shutdown)) {
/* Shutdown has been initiated. */ /* Shutdown has been initiated. */
trx->error_state = DB_INTERRUPTED; trx->error_state = DB_INTERRUPTED;
return(NULL); return(NULL);
} }
if (UNIV_UNLIKELY(trx == trx_roll_crash_recv_trx)) {
trx_roll_report_progress();
}
err = row_undo(node, thr); err = row_undo(node, thr);
trx->error_state = err; trx->error_state = err;
......
...@@ -731,21 +731,9 @@ trx_rollback_resurrected( ...@@ -731,21 +731,9 @@ trx_rollback_resurrected(
goto func_exit; goto func_exit;
} }
/** Report progress when rolling back a row of a recovered transaction. /** Report progress when rolling back a row of a recovered transaction. */
@return whether the rollback should be aborted due to pending shutdown */ UNIV_INTERN void trx_roll_report_progress()
UNIV_INTERN
bool
trx_roll_must_shutdown()
{ {
const trx_t* trx = trx_roll_crash_recv_trx;
ut_ad(trx);
ut_ad(trx_state_eq(trx, TRX_STATE_ACTIVE));
if (trx_get_dict_operation(trx) == TRX_DICT_OP_NONE
&& !srv_undo_sources && srv_fast_shutdown) {
return true;
}
ib_time_t time = ut_time(); ib_time_t time = ut_time();
mutex_enter(&trx_sys->mutex); mutex_enter(&trx_sys->mutex);
mutex_enter(&recv_sys->mutex); mutex_enter(&recv_sys->mutex);
...@@ -773,7 +761,6 @@ trx_roll_must_shutdown() ...@@ -773,7 +761,6 @@ trx_roll_must_shutdown()
mutex_exit(&recv_sys->mutex); mutex_exit(&recv_sys->mutex);
mutex_exit(&trx_sys->mutex); mutex_exit(&trx_sys->mutex);
return false;
} }
/*******************************************************************//** /*******************************************************************//**
......
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