| 1 |
/***************************************************************************** |
| 2 |
|
| 3 |
Copyright (c) 1996, 2026, Oracle and/or its affiliates. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify it under |
| 6 |
the terms of the GNU General Public License, version 2.0, as published by the |
| 7 |
Free Software Foundation. |
| 8 |
|
| 9 |
This program is designed to work with certain software (including |
| 10 |
but not limited to OpenSSL) that is licensed under separate terms, |
| 11 |
as designated in a particular file or component or in included license |
| 12 |
documentation. The authors of MySQL hereby grant you an additional |
| 13 |
permission to link the program and your derivative works with the |
| 14 |
separately licensed software that they have either included with |
| 15 |
the program or referenced in the documentation. |
| 16 |
|
| 17 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 |
FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0, |
| 20 |
for more details. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License along with |
| 23 |
this program; if not, write to the Free Software Foundation, Inc., |
| 24 |
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 25 |
|
| 26 |
*****************************************************************************/ |
| 27 |
|
| 28 |
/** @file include/trx0roll.ic |
| 29 |
Transaction rollback |
| 30 |
|
| 31 |
Created 3/26/1996 Heikki Tuuri |
| 32 |
*******************************************************/ |
| 33 |
|
| 34 |
#ifdef UNIV_DEBUG |
| 35 |
/** Check if undo numbering is maintained while processing undo records |
| 36 |
for rollback. |
| 37 |
@return true if undo numbering is maintained. */ |
| 38 |
static inline bool trx_roll_check_undo_rec_ordering( |
| 39 |
undo_no_t curr_undo_rec_no, /*!< in: record number of |
| 40 |
undo record to process. */ |
| 41 |
space_id_t curr_undo_space_id, /*!< in: space-id of rollback |
| 42 |
segment that contains the |
| 43 |
undo record to process. */ |
| 44 |
const trx_t *trx) /*!< in: transaction */ |
| 45 |
{ |
| 46 |
/* Each transaction now can have multiple rollback segments. |
| 47 |
If a transaction involves temp and non-temp tables, both the rollback |
| 48 |
segments will be active. In this case undo records will be distributed |
| 49 |
across the two rollback segments. |
| 50 |
CASE-1: UNDO action will apply all undo records from one rollback |
| 51 |
segment before moving to next. This means undo record numbers can't be |
| 52 |
sequential but ordering is still enforced as next undo record number |
| 53 |
should be < processed undo record number. |
| 54 |
CASE-2: For normal rollback (not initiated by crash) all rollback |
| 55 |
segments will be active (including non-redo). |
| 56 |
Based on transaction operation pattern undo record number of first |
| 57 |
undo record from this new rollback segment can be > last undo number |
| 58 |
from previous rollback segment and so we ignore this check if |
| 59 |
rollback segments are switching. Once switched new rollback segment |
| 60 |
should re-follow undo record number pattern (as mentioned in CASE-1). */ |
| 61 |
|
| 62 |
return (curr_undo_space_id != trx->undo_rseg_space || |
| 63 |
curr_undo_rec_no + 1 <= trx->undo_no); |
| 64 |
} |
| 65 |
#endif /* UNIV_DEBUG */ |