Commit 0ef91c89 authored by Marko Mäkelä's avatar Marko Mäkelä

Simplify InnoDB transaction system initialization.

trx_rseg_mem_create(): Remove the parameter rseg_array.
Update trx_sys->rseg_array directly.
parent 14178398
...@@ -167,17 +167,14 @@ array in the trx system object. ...@@ -167,17 +167,14 @@ array in the trx system object.
@param[in] space space where the segment is placed @param[in] space space where the segment is placed
@param[in] page_no page number of the segment header @param[in] page_no page number of the segment header
@param[in] page_size page size @param[in] page_size page size
@param[out] rseg_array add rseg reference to this central array @param[in,out] mtr mini-transaction */
@param[in,out] mtr mini-transaction
@return own: rollback segment object */
static static
trx_rseg_t* void
trx_rseg_mem_create( trx_rseg_mem_create(
ulint id, ulint id,
ulint space, ulint space,
ulint page_no, ulint page_no,
const page_size_t& page_size, const page_size_t& page_size,
trx_rseg_t** rseg_array,
mtr_t* mtr) mtr_t* mtr)
{ {
ulint len; ulint len;
...@@ -207,7 +204,7 @@ trx_rseg_mem_create( ...@@ -207,7 +204,7 @@ trx_rseg_mem_create(
UT_LIST_INIT(rseg->insert_undo_list, &trx_undo_t::undo_list); UT_LIST_INIT(rseg->insert_undo_list, &trx_undo_t::undo_list);
UT_LIST_INIT(rseg->insert_undo_cached, &trx_undo_t::undo_list); UT_LIST_INIT(rseg->insert_undo_cached, &trx_undo_t::undo_list);
*((trx_rseg_t**) rseg_array + rseg->id) = rseg; trx_sys->rseg_array[id] = rseg;
rseg_header = trx_rsegf_get_new(space, page_no, page_size, mtr); rseg_header = trx_rsegf_get_new(space, page_no, page_size, mtr);
...@@ -256,18 +253,18 @@ trx_rseg_mem_create( ...@@ -256,18 +253,18 @@ trx_rseg_mem_create(
} else { } else {
rseg->last_page_no = FIL_NULL; rseg->last_page_no = FIL_NULL;
} }
return(rseg);
} }
/** Initialize the rollback segments in memory at database startup. */ /** Initialize the rollback segments in memory at database startup. */
void void
trx_rseg_array_init() trx_rseg_array_init()
{ {
mtr_t mtr;
for (ulint i = 0; i < TRX_SYS_N_RSEGS; i++) { for (ulint i = 0; i < TRX_SYS_N_RSEGS; i++) {
ut_a(!trx_rseg_get_on_id(i));
ulint page_no; ulint page_no;
mtr_t mtr;
mtr.start(); mtr.start();
trx_sysf_t* sys_header = trx_sysf_get(&mtr); trx_sysf_t* sys_header = trx_sysf_get(&mtr);
...@@ -275,9 +272,6 @@ trx_rseg_array_init() ...@@ -275,9 +272,6 @@ trx_rseg_array_init()
if (page_no != FIL_NULL) { if (page_no != FIL_NULL) {
ulint space; ulint space;
trx_rseg_t* rseg = NULL;
ut_a(!trx_rseg_get_on_id(i));
space = trx_sysf_rseg_get_space(sys_header, i, &mtr); space = trx_sysf_rseg_get_space(sys_header, i, &mtr);
...@@ -289,17 +283,10 @@ trx_rseg_array_init() ...@@ -289,17 +283,10 @@ trx_rseg_array_init()
ut_ad(found); ut_ad(found);
trx_rseg_t** rseg_array = trx_rseg_mem_create(
static_cast<trx_rseg_t**>(trx_sys->rseg_array); i, space, page_no, page_size, &mtr);
rseg = trx_rseg_mem_create(
i, space, page_no, page_size,
rseg_array, &mtr);
ut_a(rseg->id == i);
} else {
ut_a(trx_sys->rseg_array[i] == NULL);
} }
mtr.commit(); mtr.commit();
} }
} }
...@@ -315,10 +302,8 @@ trx_rseg_create( ...@@ -315,10 +302,8 @@ trx_rseg_create(
0 means next free slots. */ 0 means next free slots. */
{ {
mtr_t mtr; mtr_t mtr;
ulint slot_no;
trx_rseg_t* rseg = NULL;
mtr_start(&mtr); mtr.start();
/* To obey the latching order, acquire the file space /* To obey the latching order, acquire the file space
x-latch before the trx_sys->mutex. */ x-latch before the trx_sys->mutex. */
...@@ -329,46 +314,34 @@ trx_rseg_create( ...@@ -329,46 +314,34 @@ trx_rseg_create(
case FIL_TYPE_IMPORT: case FIL_TYPE_IMPORT:
ut_ad(0); ut_ad(0);
case FIL_TYPE_TEMPORARY: case FIL_TYPE_TEMPORARY:
mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO); mtr.set_log_mode(MTR_LOG_NO_REDO);
break; break;
case FIL_TYPE_TABLESPACE: case FIL_TYPE_TABLESPACE:
break; break;
} }
slot_no = trx_sysf_rseg_find_free(
&mtr, space->purpose == FIL_TYPE_TEMPORARY, nth_free_slot);
if (slot_no != ULINT_UNDEFINED) {
ulint id;
ulint page_no;
trx_sysf_t* sys_header;
page_size_t page_size(space->flags); page_size_t page_size(space->flags);
ulint slot_no = trx_sysf_rseg_find_free(
page_no = trx_rseg_header_create( &mtr, space->purpose == FIL_TYPE_TEMPORARY, nth_free_slot);
ulint page_no = slot_no == ULINT_UNDEFINED
? FIL_NULL
: trx_rseg_header_create(
space_id, page_size, ULINT_MAX, slot_no, &mtr); space_id, page_size, ULINT_MAX, slot_no, &mtr);
if (page_no == FIL_NULL) { if (page_no != FIL_NULL) {
mtr_commit(&mtr); trx_sysf_t* sys_header = trx_sysf_get(&mtr);
return(rseg);
}
sys_header = trx_sysf_get(&mtr);
id = trx_sysf_rseg_get_space(sys_header, slot_no, &mtr); ulint id = trx_sysf_rseg_get_space(
sys_header, slot_no, &mtr);
ut_a(id == space_id || trx_sys_is_noredo_rseg_slot(slot_no)); ut_a(id == space_id || trx_sys_is_noredo_rseg_slot(slot_no));
trx_rseg_t** rseg_array = trx_rseg_mem_create(
((trx_rseg_t**) trx_sys->rseg_array); slot_no, space_id, page_no, page_size, &mtr);
rseg = trx_rseg_mem_create(
slot_no, space_id, page_no, page_size,
rseg_array, &mtr);
} }
mtr_commit(&mtr); mtr.commit();
return(rseg); return(page_no == FIL_NULL ? NULL : trx_sys->rseg_array[slot_no]);
} }
/******************************************************************** /********************************************************************
......
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