1
1
/*****************************************************************************
3
Copyright (c) 1996, 2009, Innobase Oy. All Rights Reserved.
3
Copyright (c) 1996, 2011, Oracle and/or its affiliates. All Rights Reserved.
5
5
This program is free software; you can redistribute it and/or modify it under
6
6
the terms of the GNU General Public License as published by the Free Software
999
1000
/********************************************************************//**
1000
Frees an undo log page when there is also the memory object for the undo
1001
Frees the last undo log page.
1002
The caller must hold the rollback segment mutex. */
1004
trx_undo_free_page_in_rollback(
1005
/*===========================*/
1006
trx_t* trx __attribute__((unused)), /*!< in: transaction */
1007
trx_undo_t* undo, /*!< in: undo log memory copy */
1008
ulint page_no,/*!< in: page number to free: must not be the
1010
mtr_t* mtr) /*!< in: mtr which does not have a latch to any
1011
undo log page; the caller must have reserved
1012
the rollback segment mutex */
1005
trx_undo_free_last_page_func(
1006
/*==========================*/
1008
const trx_t* trx, /*!< in: transaction */
1009
#endif /* UNIV_DEBUG */
1010
trx_undo_t* undo, /*!< in/out: undo log memory copy */
1011
mtr_t* mtr) /*!< in/out: mini-transaction which does not
1012
have a latch to any undo log page or which
1013
has allocated the undo log page */
1016
ut_ad(undo->hdr_page_no != page_no);
1017
ut_ad(mutex_own(&(trx->undo_mutex)));
1019
last_page_no = trx_undo_free_page(undo->rseg, FALSE, undo->space,
1020
undo->hdr_page_no, page_no, mtr);
1022
undo->last_page_no = last_page_no;
1015
ut_ad(mutex_own(&trx->undo_mutex));
1016
ut_ad(undo->hdr_page_no != undo->last_page_no);
1017
ut_ad(undo->size > 0);
1019
undo->last_page_no = trx_undo_free_page(
1020
undo->rseg, FALSE, undo->space,
1021
undo->hdr_page_no, undo->last_page_no, mtr);
1055
1055
to free space from an undo log. */
1058
trx_undo_truncate_end(
1059
/*==================*/
1060
trx_t* trx, /*!< in: transaction whose undo log it is */
1058
trx_undo_truncate_end_func(
1059
/*=======================*/
1061
const trx_t* trx, /*!< in: transaction whose undo log it is */
1062
#endif /* UNIV_DEBUG */
1061
1063
trx_undo_t* undo, /*!< in: undo log */
1062
1064
undo_no_t limit) /*!< in: all undo records with undo number
1063
1065
>= this value should be truncated */
1087
1086
rec = trx_undo_page_get_last_rec(undo_page, undo->hdr_page_no,
1088
1087
undo->hdr_offset);
1091
if (last_page_no == undo->hdr_page_no) {
1096
trx_undo_free_page_in_rollback(
1097
trx, undo, last_page_no, &mtr);
1101
1089
if (ut_dulint_cmp(trx_undo_rec_get_undo_no(rec), limit)
1103
1091
/* Truncate at least this record off, maybe
1827
1823
if (undo->size == 1
1828
1824
&& mach_read_from_2(page_hdr + TRX_UNDO_PAGE_FREE)
1829
< TRX_UNDO_PAGE_REUSE_LIMIT) {
1831
/* This is a heuristic to avoid the problem of all UNDO
1832
slots ending up in one of the UNDO lists. Previously if
1833
the server crashed with all the slots in one of the lists,
1834
transactions that required the slots of a different type
1835
would fail for lack of slots. */
1837
if (UT_LIST_GET_LEN(rseg->update_undo_list) < 500
1838
&& UT_LIST_GET_LEN(rseg->insert_undo_list) < 500) {
1840
state = TRX_UNDO_CACHED;
1842
state = TRX_UNDO_TO_FREE;
1825
< TRX_UNDO_PAGE_REUSE_LIMIT
1826
&& UT_LIST_GET_LEN(rseg->update_undo_list) < 500
1827
&& UT_LIST_GET_LEN(rseg->insert_undo_list) < 500) {
1829
state = TRX_UNDO_CACHED;
1845
1831
} else if (undo->type == TRX_UNDO_INSERT) {
1939
1923
UT_LIST_ADD_FIRST(undo_list, rseg->update_undo_cached, undo);
1941
ut_ad(undo->state == TRX_UNDO_TO_PURGE);
1925
ut_ad(undo->state == TRX_UNDO_TO_PURGE
1926
|| undo->state == TRX_UNDO_TO_FREE);
1943
1928
trx_undo_mem_free(undo);
1991
1976
mutex_exit(&(rseg->mutex));
1979
/********************************************************************//**
1980
At shutdown, frees the undo logs of a PREPARED transaction. */
1983
trx_undo_free_prepared(
1984
/*===================*/
1985
trx_t* trx) /*!< in/out: PREPARED transaction */
1987
ut_ad(srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS);
1989
if (trx->update_undo) {
1990
ut_a(trx->update_undo->state == TRX_UNDO_PREPARED);
1991
UT_LIST_REMOVE(undo_list, trx->rseg->update_undo_list,
1993
trx_undo_mem_free(trx->update_undo);
1995
if (trx->insert_undo) {
1996
ut_a(trx->insert_undo->state == TRX_UNDO_PREPARED);
1997
UT_LIST_REMOVE(undo_list, trx->rseg->insert_undo_list,
1999
trx_undo_mem_free(trx->insert_undo);
1993
2002
#endif /* !UNIV_HOTBACKUP */