Browse Source
Bug #11766227: InnoDB purge lag much worse for 5.5.8 versus 5.1
Bug #11766227: InnoDB purge lag much worse for 5.5.8 versus 5.1
Bug #11766501: Multiple RBS break the get rseg with mininum trx_t::no code during purge Bug# 59291 changes: Main problem is that truncating the UNDO log at the completion of every trx_purge() call is expensive as the number of rollback segments is increased. We truncate after a configurable amount of pages. The innodb_purge_batch_size parameter is used to control when InnoDB does the actual truncate. The truncate is done once after 128 (or TRX_SYS_N_RSEGS iterations). In other words we truncate after purge 128 * innodb_purge_batch_size. The smaller the batch size the quicker we truncate. Introduce a new parameter that allows how many rollback segments to use for storing REDO information. This is really step 1 in allowing complete control to the user over rollback space management. New parameters: i) innodb_rollback_segments = number of rollback_segments to use (default is now 128) dynamic parameter, can be changed anytime. Currently there is little benefit in changing it from the default. Optimisations in the patch. i. Change the O(n) behaviour of trx_rseg_get_on_id() to O(log n) Backported from 5.6. Refactor some of the binary heap code. Create a new include/ut0bh.ic file. ii. Avoid truncating the rollback segments after every purge. Related changes that were moved to a separate patch: i. Purge should not do any flushing, only wait for space to be free so that it only does purging of records unless it is held up by a long running transaction that is preventing it from progressing. ii. Give the purge thread preference over transactions when acquiring the rseg->mutex during commit. This to avoid purge blocking unnecessarily when getting the next rollback segment to purge. Bug #11766501 changes: Add the rseg to the min binary heap under the cover of the kernel mutex and the binary heap mutex. This ensures the ordering of the min binary heap. The two changes have to be committed together because they share the same that fixes both issues. rb://567 Approved by: Inaam Rana.pull/374/head
17 changed files with 652 additions and 372 deletions
-
4storage/innobase/CMakeLists.txt
-
20storage/innobase/handler/ha_innodb.cc
-
13storage/innobase/include/buf0flu.h
-
7storage/innobase/include/srv0srv.h
-
6storage/innobase/include/sync0sync.h
-
22storage/innobase/include/trx0purge.h
-
12storage/innobase/include/trx0rseg.h
-
10storage/innobase/include/trx0sys.h
-
12storage/innobase/include/trx0sys.ic
-
123storage/innobase/include/ut0bh.ic
-
22storage/innobase/srv/srv0srv.c
-
14storage/innobase/sync/sync0sync.c
-
399storage/innobase/trx/trx0purge.c
-
52storage/innobase/trx/trx0rseg.c
-
43storage/innobase/trx/trx0sys.c
-
256storage/innobase/trx/trx0trx.c
-
9storage/innobase/ut/ut0ut.c
@ -0,0 +1,123 @@ |
|||
/***************************************************************************//** |
|||
Copyright (c) 2011, Oracle Corpn. All Rights Reserved. |
|||
|
|||
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 |
|||
Foundation; version 2 of the License. |
|||
|
|||
This program is distributed in the hope that it will be useful, but WITHOUT |
|||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|||
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License along with |
|||
this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|||
Place, Suite 330, Boston, MA 02111-1307 USA |
|||
|
|||
*****************************************************************************/ |
|||
|
|||
/******************************************************************//** |
|||
@file include/ut0bh.ic |
|||
Binary min-heap implementation. |
|||
|
|||
Created 2011-01-15 by Sunny Bains |
|||
*******************************************************/ |
|||
|
|||
#include "ut0bh.h" |
|||
|
|||
/**********************************************************************//** |
|||
Get the number of elements in the binary heap. |
|||
@return number of elements */ |
|||
UNIV_INLINE |
|||
ulint |
|||
ib_bh_size( |
|||
/*=======*/ |
|||
const ib_bh_t* ib_bh) /*!< in: instance */ |
|||
{ |
|||
return(ib_bh->n_elems); |
|||
} |
|||
|
|||
/**********************************************************************//** |
|||
Test if binary heap is empty. |
|||
@return TRUE if empty. */ |
|||
UNIV_INLINE |
|||
ibool |
|||
ib_bh_is_empty( |
|||
/*===========*/ |
|||
const ib_bh_t* ib_bh) /*!< in: instance */ |
|||
{ |
|||
return(ib_bh_size(ib_bh) == 0); |
|||
} |
|||
|
|||
/**********************************************************************//** |
|||
Test if binary heap is full. |
|||
@return TRUE if full. */ |
|||
UNIV_INLINE |
|||
ibool |
|||
ib_bh_is_full( |
|||
/*===========*/ |
|||
const ib_bh_t* ib_bh) /*!< in: instance */ |
|||
{ |
|||
return(ib_bh_size(ib_bh) >= ib_bh->max_elems); |
|||
} |
|||
|
|||
/**********************************************************************//** |
|||
Get a pointer to the element. |
|||
@return pointer to element */ |
|||
UNIV_INLINE |
|||
void* |
|||
ib_bh_get( |
|||
/*=======*/ |
|||
ib_bh_t* ib_bh, /*!< in: instance */ |
|||
ulint i) /*!< in: index */ |
|||
{ |
|||
byte* ptr = (byte*) (ib_bh + 1); |
|||
|
|||
ut_a(i < ib_bh_size(ib_bh)); |
|||
|
|||
return(ptr + (ib_bh->sizeof_elem * i)); |
|||
} |
|||
|
|||
/**********************************************************************//** |
|||
Copy an element to the binary heap. |
|||
@return pointer to copied element */ |
|||
UNIV_INLINE |
|||
void* |
|||
ib_bh_set( |
|||
/*======*/ |
|||
ib_bh_t* ib_bh, /*!< in/out: instance */ |
|||
ulint i, /*!< in: index */ |
|||
const void* elem) /*!< in: element to add */ |
|||
{ |
|||
void* ptr = ib_bh_get(ib_bh, i); |
|||
|
|||
ut_memcpy(ptr, elem, ib_bh->sizeof_elem); |
|||
|
|||
return(ptr); |
|||
} |
|||
|
|||
/**********************************************************************//** |
|||
Return the first element from the binary heap. |
|||
@return pointer to first element or NULL if empty. */ |
|||
UNIV_INLINE |
|||
void* |
|||
ib_bh_first( |
|||
/*========*/ |
|||
ib_bh_t* ib_bh) /*!< in: instance */ |
|||
{ |
|||
return(ib_bh_is_empty(ib_bh) ? NULL : ib_bh_get(ib_bh, 0)); |
|||
} |
|||
|
|||
/**********************************************************************//** |
|||
Return the last element from the binary heap. |
|||
@return pointer to last element or NULL if empty. */ |
|||
UNIV_INLINE |
|||
void* |
|||
ib_bh_last( |
|||
/*========*/ |
|||
ib_bh_t* ib_bh) /*!< in/out: instance */ |
|||
{ |
|||
return(ib_bh_is_empty(ib_bh) |
|||
? NULL |
|||
: ib_bh_get(ib_bh, ib_bh_size(ib_bh) - 1)); |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue