Skip to content

Commit 15bdfee

Browse files
committed
Remove trx_sys_t::pending_purge_rseg_array.
In MySQL 5.7, there is some redundant code for supposedly handling an upgrade from an earlier version of InnoDB. An upgrade of InnoDB between major versions should include a slow shutdown (innodb_fast_shutdown=0) of the previous version. A comment in trx_lists_init_at_db_start() confused clean shutdown and slow shutdown. A clean shutdown does not necessarily guarantee that there are no active transactions. A slow shutdown guarantees that. Because there was no code to handle rollback of recovered transactions that happened to use the rollback segment slots that MySQL 5.7.2 repurposed for temporary undo logs, the upgrade is not working in all cases, and we may as well remove the code to handle purging. trx_sys_t::pending_purge_rseg_array: Remove. trx_undo_get_undo_rec_low(): Define as static. Remove the parameter is_redo_rseg. trx_undo_get_undo_rec(), trx_rseg_get_on_id(): Remove the parameter is_redo_rseg. trx_rseg_mem_free(): Remove the second parameter. trx_sys_get_nth_rseg(): Replace with trx_rseg_get_on_id(). trx_rseg_schedule_pending_purge(): Remove.
1 parent 24cbc8d commit 15bdfee

File tree

11 files changed

+26
-213
lines changed

11 files changed

+26
-213
lines changed

storage/innobase/include/trx0rec.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,6 @@ trx_undo_report_row_operation(
219219
0 if BTR_NO_UNDO_LOG
220220
flag was specified */
221221
MY_ATTRIBUTE((nonnull(3,4,10), warn_unused_result));
222-
/******************************************************************//**
223-
Copies an undo record to heap. This function can be called if we know that
224-
the undo log record exists.
225-
@return own: copy of the record */
226-
trx_undo_rec_t*
227-
trx_undo_get_undo_rec_low(
228-
/*======================*/
229-
roll_ptr_t roll_ptr, /*!< in: roll pointer to record */
230-
mem_heap_t* heap, /*!< in: memory heap where copied */
231-
bool is_redo_rseg) /*!< in: true if redo rseg. */
232-
MY_ATTRIBUTE((nonnull, warn_unused_result));
233222

234223
/** status bit used for trx_undo_prev_version_build() */
235224

storage/innobase/include/trx0rseg.h

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -26,7 +27,6 @@ Created 3/26/1996 Heikki Tuuri
2627
#ifndef trx0rseg_h
2728
#define trx0rseg_h
2829

29-
#include "univ.i"
3030
#include "trx0types.h"
3131
#include "trx0sys.h"
3232
#include "fut0lst.h"
@@ -89,15 +89,16 @@ trx_rsegf_undo_find_free(
8989
/*=====================*/
9090
trx_rsegf_t* rsegf, /*!< in: rollback segment header */
9191
mtr_t* mtr); /*!< in: mtr */
92-
/******************************************************************//**
93-
Looks for a rollback segment, based on the rollback segment id.
92+
/** Get a rollback segment.
93+
@param[in] id rollback segment id
9494
@return rollback segment */
9595
UNIV_INLINE
9696
trx_rseg_t*
97-
trx_rseg_get_on_id(
98-
/*===============*/
99-
ulint id, /*!< in: rollback segment id */
100-
bool is_redo_rseg); /*!< in: true if redo rseg else false. */
97+
trx_rseg_get_on_id(ulint id)
98+
{
99+
ut_a(id < TRX_SYS_N_RSEGS);
100+
return(trx_sys->rseg_array[id]);
101+
}
101102

102103
/** Creates a rollback segment header.
103104
This function is called only when a new rollback segment is created in
@@ -124,14 +125,10 @@ trx_rseg_array_init(
124125
/*================*/
125126
purge_pq_t* purge_queue); /*!< in: rseg queue */
126127

127-
/***************************************************************************
128-
Free's an instance of the rollback segment in memory. */
128+
/** Free a rollback segment in memory. */
129129
void
130-
trx_rseg_mem_free(
131-
/*==============*/
132-
trx_rseg_t* rseg, /*!< in, own: instance to free */
133-
trx_rseg_t** rseg_array); /*!< out: add rseg reference to this
134-
central array. */
130+
trx_rseg_mem_free(trx_rseg_t* rseg);
131+
135132
/*********************************************************************
136133
Creates a rollback segment. */
137134
trx_rseg_t*

storage/innobase/include/trx0rseg.ic

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22

33
Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45

56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -25,7 +26,6 @@ Created 3/26/1996 Heikki Tuuri
2526

2627
#include "srv0srv.h"
2728
#include "mtr0log.h"
28-
#include "trx0sys.h"
2929

3030
/** Gets a rollback segment header.
3131
@param[in] space space where placed
@@ -146,28 +146,3 @@ trx_rsegf_undo_find_free(
146146

147147
return(ULINT_UNDEFINED);
148148
}
149-
150-
/******************************************************************//**
151-
Looks for a rollback segment, based on the rollback segment id.
152-
@return rollback segment */
153-
UNIV_INLINE
154-
trx_rseg_t*
155-
trx_rseg_get_on_id(
156-
/*===============*/
157-
ulint id, /*!< in: rollback segment id */
158-
bool is_redo_rseg) /*!< in: true if redo rseg else false. */
159-
{
160-
ut_a(id < TRX_SYS_N_RSEGS);
161-
162-
/* If redo rseg is being requested and id falls in range of
163-
non-redo rseg that is from slot-1....slot-srv_tmp_undo_logs then
164-
server is being upgraded from pre-5.7.2. In such case return
165-
rseg from pending_purge_rseg_array array. */
166-
if (is_redo_rseg && trx_sys_is_noredo_rseg_slot(id)) {
167-
ut_ad(trx_sys->pending_purge_rseg_array[id] != NULL);
168-
return(trx_sys->pending_purge_rseg_array[id]);
169-
}
170-
171-
return(trx_sys->rseg_array[id]);
172-
}
173-

storage/innobase/include/trx0sys.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,6 @@ trx_sysf_rseg_find_free(
8989
for temp-tablespace as free slots. */
9090
ulint nth_free_slots); /*!< in: allocate nth free slot.
9191
0 means next free slot. */
92-
/***************************************************************//**
93-
Gets the pointer in the nth slot of the rseg array.
94-
@return pointer to rseg object, NULL if slot not in use */
95-
UNIV_INLINE
96-
trx_rseg_t*
97-
trx_sys_get_nth_rseg(
98-
/*=================*/
99-
trx_sys_t* sys, /*!< in: trx system */
100-
ulint n, /*!< in: index of slot */
101-
bool is_redo_rseg); /*!< in: true if redo rseg. */
10292
/**********************************************************************//**
10393
Gets a pointer to the transaction system file copy and x-locks its page.
10494
@return pointer to system file copy, page x-locked */
@@ -619,14 +609,6 @@ struct trx_sys_t {
619609
transactions), protected by
620610
rseg->mutex */
621611

622-
trx_rseg_t* const pending_purge_rseg_array[TRX_SYS_N_RSEGS];
623-
/*!< Pointer array to rollback segments
624-
between slot-1..slot-srv_tmp_undo_logs
625-
that are now replaced by non-redo
626-
rollback segments. We need them for
627-
scheduling purge if any of the rollback
628-
segment has pending records to purge. */
629-
630612
TrxIdSet rw_trx_set; /*!< Mapping from transaction id
631613
to transaction instance */
632614

storage/innobase/include/trx0sys.ic

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,31 +62,6 @@ trx_sys_hdr_page(
6262
&& page_id.page_no() == TRX_SYS_PAGE_NO);
6363
}
6464

65-
/***************************************************************//**
66-
Gets the pointer in the nth slot of the rseg array.
67-
@return pointer to rseg object, NULL if slot not in use */
68-
UNIV_INLINE
69-
trx_rseg_t*
70-
trx_sys_get_nth_rseg(
71-
/*=================*/
72-
trx_sys_t* sys, /*!< in: trx system */
73-
ulint n, /*!< in: index of slot */
74-
bool is_redo_rseg) /*!< in: true if redo rseg. */
75-
{
76-
ut_ad(n < TRX_SYS_N_RSEGS);
77-
78-
/* If redo rseg is being requested and id falls in range of
79-
non-redo rseg that is from slot-1....slot-srv_tmp_undo_logs then
80-
server is being upgraded from pre-5.7.2. In such case return
81-
rseg from pending_purge_rseg_array array. */
82-
if (is_redo_rseg && trx_sys_is_noredo_rseg_slot(n)) {
83-
ut_ad(trx_sys->pending_purge_rseg_array[n] != NULL);
84-
return(trx_sys->pending_purge_rseg_array[n]);
85-
}
86-
87-
return(sys->rseg_array[n]);
88-
}
89-
9065
/**********************************************************************//**
9166
Gets a pointer to the transaction system header and x-latches its page.
9267
@return pointer to system header, page x-latched. */

storage/innobase/row/row0purge.cc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -745,13 +745,7 @@ row_purge_upd_exist_or_extern_func(
745745
&is_insert, &rseg_id,
746746
&page_no, &offset);
747747

748-
/* If table is temp then it can't have its undo log
749-
residing in rollback segment with REDO log enabled. */
750-
bool is_redo_rseg =
751-
dict_table_is_temporary(node->table)
752-
? false : true;
753-
rseg = trx_sys_get_nth_rseg(
754-
trx_sys, rseg_id, is_redo_rseg);
748+
rseg = trx_rseg_get_on_id(rseg_id);
755749

756750
ut_a(rseg != NULL);
757751
ut_a(rseg->id == rseg_id);

storage/innobase/trx/trx0purge.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,15 +1201,6 @@ trx_purge_truncate_history(
12011201
}
12021202
}
12031203

1204-
for (i = 0; i < TRX_SYS_N_RSEGS; ++i) {
1205-
trx_rseg_t* rseg = trx_sys->pending_purge_rseg_array[i];
1206-
1207-
if (rseg != NULL) {
1208-
ut_a(rseg->id == i);
1209-
trx_purge_truncate_rseg_history(rseg, limit);
1210-
}
1211-
}
1212-
12131204
/* UNDO tablespace truncate. We will try to truncate as much as we
12141205
can (greedy approach). This will ensure when the server is idle we
12151206
try and truncate all the UNDO tablespaces. */

storage/innobase/trx/trx0rec.cc

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,12 +2104,12 @@ trx_undo_report_row_operation(
21042104
Copies an undo record to heap. This function can be called if we know that
21052105
the undo log record exists.
21062106
@return own: copy of the record */
2107+
static
21072108
trx_undo_rec_t*
21082109
trx_undo_get_undo_rec_low(
21092110
/*======================*/
21102111
roll_ptr_t roll_ptr, /*!< in: roll pointer to record */
2111-
mem_heap_t* heap, /*!< in: memory heap where copied */
2112-
bool is_redo_rseg) /*!< in: true if redo rseg. */
2112+
mem_heap_t* heap) /*!< in: memory heap where copied */
21132113
{
21142114
trx_undo_rec_t* undo_rec;
21152115
ulint rseg_id;
@@ -2122,7 +2122,7 @@ trx_undo_get_undo_rec_low(
21222122

21232123
trx_undo_decode_roll_ptr(roll_ptr, &is_insert, &rseg_id, &page_no,
21242124
&offset);
2125-
rseg = trx_rseg_get_on_id(rseg_id, is_redo_rseg);
2125+
rseg = trx_rseg_get_on_id(rseg_id);
21262126

21272127
mtr_start(&mtr);
21282128

@@ -2144,7 +2144,6 @@ Copies an undo record to heap.
21442144
the roll pointer: it points to an
21452145
undo log of this transaction
21462146
@param[in] heap memory heap where copied
2147-
@param[in] is_redo_rseg true if redo rseg.
21482147
@param[in] name table name
21492148
@param[out] undo_rec own: copy of the record
21502149
@retval true if the undo log has been
@@ -2158,7 +2157,6 @@ trx_undo_get_undo_rec(
21582157
roll_ptr_t roll_ptr,
21592158
trx_id_t trx_id,
21602159
mem_heap_t* heap,
2161-
bool is_redo_rseg,
21622160
const table_name_t& name,
21632161
trx_undo_rec_t** undo_rec)
21642162
{
@@ -2168,8 +2166,7 @@ trx_undo_get_undo_rec(
21682166

21692167
missing_history = purge_sys->view.changes_visible(trx_id, name);
21702168
if (!missing_history) {
2171-
*undo_rec = trx_undo_get_undo_rec_low(
2172-
roll_ptr, heap, is_redo_rseg);
2169+
*undo_rec = trx_undo_get_undo_rec_low(roll_ptr, heap);
21732170
}
21742171

21752172
rw_lock_s_unlock(&purge_sys->latch);
@@ -2252,17 +2249,11 @@ trx_undo_prev_version_build(
22522249

22532250
rec_trx_id = row_get_rec_trx_id(rec, index, offsets);
22542251

2255-
/* REDO rollback segment are used only for non-temporary objects.
2256-
For temporary objects NON-REDO rollback segments are used. */
2257-
bool is_redo_rseg =
2258-
dict_table_is_temporary(index->table) ? false : true;
22592252
if (trx_undo_get_undo_rec(
2260-
roll_ptr, rec_trx_id, heap, is_redo_rseg,
2261-
index->table->name, &undo_rec)) {
2253+
roll_ptr, rec_trx_id, heap, index->table->name, &undo_rec)) {
22622254
if (v_status & TRX_UNDO_PREV_IN_PURGE) {
22632255
/* We are fetching the record being purged */
2264-
undo_rec = trx_undo_get_undo_rec_low(
2265-
roll_ptr, heap, is_redo_rseg);
2256+
undo_rec = trx_undo_get_undo_rec_low(roll_ptr, heap);
22662257
} else {
22672258
/* The undo record may already have been purged,
22682259
during purge or semi-consistent read. */

storage/innobase/trx/trx0rseg.cc

Lines changed: 5 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1996, 2015, Oracle and/or its affiliates. All Rights Reserved.
4+
Copyright (c) 2017, MariaDB Corporation.
45
56
This program is free software; you can redistribute it and/or modify it under
67
the terms of the GNU General Public License as published by the Free Software
@@ -116,14 +117,9 @@ trx_rseg_header_create(
116117
return(page_no);
117118
}
118119

119-
/***********************************************************************//**
120-
Free's an instance of the rollback segment in memory. */
120+
/** Free a rollback segment in memory. */
121121
void
122-
trx_rseg_mem_free(
123-
/*==============*/
124-
trx_rseg_t* rseg, /* in, own: instance to free */
125-
trx_rseg_t** rseg_array) /*!< out: add rseg reference to this
126-
central array. */
122+
trx_rseg_mem_free(trx_rseg_t* rseg)
127123
{
128124
trx_undo_t* undo;
129125
trx_undo_t* next_undo;
@@ -160,9 +156,6 @@ trx_rseg_mem_free(
160156
trx_undo_mem_free(undo);
161157
}
162158

163-
ut_a(*((trx_rseg_t**) rseg_array + rseg->id) == rseg);
164-
*((trx_rseg_t**) rseg_array + rseg->id) = NULL;
165-
166159
ut_free(rseg);
167160
}
168161

@@ -269,49 +262,6 @@ trx_rseg_mem_create(
269262
return(rseg);
270263
}
271264

272-
/********************************************************************
273-
Check if rseg in given slot needs to be scheduled for purge. */
274-
static
275-
void
276-
trx_rseg_schedule_pending_purge(
277-
/*============================*/
278-
trx_sysf_t* sys_header, /*!< in: trx system header */
279-
purge_pq_t* purge_queue, /*!< in/out: rseg queue */
280-
ulint slot, /*!< in: check rseg from given slot. */
281-
mtr_t* mtr) /*!< in: mtr */
282-
{
283-
ulint page_no;
284-
ulint space;
285-
286-
page_no = trx_sysf_rseg_get_page_no(sys_header, slot, mtr);
287-
space = trx_sysf_rseg_get_space(sys_header, slot, mtr);
288-
289-
if (page_no != FIL_NULL
290-
&& is_system_or_undo_tablespace(space)) {
291-
292-
/* rseg resides in system or undo tablespace and so
293-
this is an upgrade scenario. trx_rseg_mem_create
294-
will add rseg to purge queue if needed. */
295-
296-
trx_rseg_t* rseg = NULL;
297-
bool found = true;
298-
const page_size_t& page_size
299-
= is_system_tablespace(space)
300-
? univ_page_size
301-
: fil_space_get_page_size(space, &found);
302-
303-
ut_ad(found);
304-
305-
trx_rseg_t** rseg_array =
306-
((trx_rseg_t**) trx_sys->pending_purge_rseg_array);
307-
rseg = trx_rseg_mem_create(
308-
slot, space, page_no, page_size,
309-
purge_queue, rseg_array, mtr);
310-
311-
ut_a(rseg->id == slot);
312-
}
313-
}
314-
315265
/********************************************************************
316266
Creates the memory copies for the rollback segments and initializes the
317267
rseg array in trx_sys at a database startup. */
@@ -332,22 +282,11 @@ trx_rseg_create_instance(
332282

333283
page_no = trx_sysf_rseg_get_page_no(sys_header, i, &mtr);
334284

335-
/* Slot-1....Slot-n are reserved for non-redo rsegs.
336-
Non-redo rsegs are recreated on server re-start so
337-
avoid initializing the existing non-redo rsegs. */
338-
if (trx_sys_is_noredo_rseg_slot(i)) {
339-
340-
/* If this is an upgrade scenario then existing rsegs
341-
in range from slot-1....slot-n needs to be scheduled
342-
for purge if there are pending purge operation. */
343-
trx_rseg_schedule_pending_purge(
344-
sys_header, purge_queue, i, &mtr);
345-
346-
} else if (page_no != FIL_NULL) {
285+
if (page_no != FIL_NULL) {
347286
ulint space;
348287
trx_rseg_t* rseg = NULL;
349288

350-
ut_a(!trx_rseg_get_on_id(i, true));
289+
ut_a(!trx_rseg_get_on_id(i));
351290

352291
space = trx_sysf_rseg_get_space(sys_header, i, &mtr);
353292

0 commit comments

Comments
 (0)