Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
19372f10
Commit
19372f10
authored
Feb 23, 2011
by
Vasil Dimov
Browse files
Options
Browse Files
Download
Plain Diff
Merge mysql-5.5-innodb -> mysql-5.5
parents
0c9dde5c
9f699b39
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
971 additions
and
371 deletions
+971
-371
mysql-test/suite/sys_vars/r/all_vars.result
mysql-test/suite/sys_vars/r/all_vars.result
+2
-0
storage/innobase/CMakeLists.txt
storage/innobase/CMakeLists.txt
+2
-2
storage/innobase/handler/ha_innodb.cc
storage/innobase/handler/ha_innodb.cc
+13
-5
storage/innobase/include/buf0flu.h
storage/innobase/include/buf0flu.h
+12
-1
storage/innobase/include/srv0srv.h
storage/innobase/include/srv0srv.h
+5
-2
storage/innobase/include/sync0sync.h
storage/innobase/include/sync0sync.h
+3
-3
storage/innobase/include/trx0purge.h
storage/innobase/include/trx0purge.h
+14
-8
storage/innobase/include/trx0rseg.h
storage/innobase/include/trx0rseg.h
+11
-1
storage/innobase/include/trx0sys.h
storage/innobase/include/trx0sys.h
+2
-8
storage/innobase/include/trx0sys.ic
storage/innobase/include/trx0sys.ic
+0
-12
storage/innobase/include/ut0bh.h
storage/innobase/include/ut0bh.h
+152
-0
storage/innobase/include/ut0bh.ic
storage/innobase/include/ut0bh.ic
+125
-0
storage/innobase/srv/srv0srv.c
storage/innobase/srv/srv0srv.c
+17
-5
storage/innobase/sync/sync0sync.c
storage/innobase/sync/sync0sync.c
+10
-4
storage/innobase/trx/trx0purge.c
storage/innobase/trx/trx0purge.c
+205
-194
storage/innobase/trx/trx0rseg.c
storage/innobase/trx/trx0rseg.c
+36
-16
storage/innobase/trx/trx0sys.c
storage/innobase/trx/trx0sys.c
+39
-4
storage/innobase/trx/trx0trx.c
storage/innobase/trx/trx0trx.c
+158
-98
storage/innobase/ut/ut0bh.c
storage/innobase/ut/ut0bh.c
+164
-0
storage/innobase/ut/ut0ut.c
storage/innobase/ut/ut0ut.c
+1
-8
No files found.
mysql-test/suite/sys_vars/r/all_vars.result
View file @
19372f10
...
@@ -11,8 +11,10 @@ There should be *no* long test name listed below:
...
@@ -11,8 +11,10 @@ There should be *no* long test name listed below:
select variable_name as `There should be *no* variables listed below:` from t2
select variable_name as `There should be *no* variables listed below:` from t2
left join t1 on variable_name=test_name where test_name is null;
left join t1 on variable_name=test_name where test_name is null;
There should be *no* variables listed below:
There should be *no* variables listed below:
INNODB_ROLLBACK_SEGMENTS
INNODB_STATS_METHOD
INNODB_STATS_METHOD
INNODB_FILE_FORMAT_MAX
INNODB_FILE_FORMAT_MAX
INNODB_ROLLBACK_SEGMENTS
INNODB_STATS_METHOD
INNODB_STATS_METHOD
INNODB_FILE_FORMAT_MAX
INNODB_FILE_FORMAT_MAX
drop table t1;
drop table t1;
...
...
storage/innobase/CMakeLists.txt
View file @
19372f10
# Copyright (c) 2006, 201
0
, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2006, 201
1
, Oracle and/or its affiliates. All rights reserved.
#
#
# This program is free software; you can redistribute it and/or modify
# 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
# it under the terms of the GNU General Public License as published by
...
@@ -246,7 +246,7 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
...
@@ -246,7 +246,7 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c
trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c
usr/usr0sess.c
usr/usr0sess.c
ut/ut0byte.c ut/ut0dbg.c ut/ut0list.c ut/ut0mem.c ut/ut0rbt.c ut/ut0rnd.c
ut/ut0byte.c ut/ut0dbg.c ut/ut0list.c ut/ut0mem.c ut/ut0rbt.c ut/ut0rnd.c
ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c
)
ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c
ut/ut0bh.c
)
IF
(
WITH_INNODB
)
IF
(
WITH_INNODB
)
# Legacy option
# Legacy option
...
...
storage/innobase/handler/ha_innodb.cc
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 2000, 201
0
, MySQL AB & Innobase Oy. All Rights Reserved.
Copyright (c) 2000, 201
1
, MySQL AB & Innobase Oy. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2009, Percona Inc.
...
@@ -262,7 +262,7 @@ static PSI_mutex_info all_innodb_mutexes[] = {
...
@@ -262,7 +262,7 @@ static PSI_mutex_info all_innodb_mutexes[] = {
# endif
/* UNIV_MEM_DEBUG */
# endif
/* UNIV_MEM_DEBUG */
{
&
mem_pool_mutex_key
,
"mem_pool_mutex"
,
0
},
{
&
mem_pool_mutex_key
,
"mem_pool_mutex"
,
0
},
{
&
mutex_list_mutex_key
,
"mutex_list_mutex"
,
0
},
{
&
mutex_list_mutex_key
,
"mutex_list_mutex"
,
0
},
{
&
purge_sys_
mutex_key
,
"purge_sys
_mutex"
,
0
},
{
&
purge_sys_
bh_mutex_key
,
"purge_sys_bh
_mutex"
,
0
},
{
&
recv_sys_mutex_key
,
"recv_sys_mutex"
,
0
},
{
&
recv_sys_mutex_key
,
"recv_sys_mutex"
,
0
},
{
&
rseg_mutex_key
,
"rseg_mutex"
,
0
},
{
&
rseg_mutex_key
,
"rseg_mutex"
,
0
},
# ifdef UNIV_SYNC_DEBUG
# ifdef UNIV_SYNC_DEBUG
...
@@ -10982,16 +10982,23 @@ static MYSQL_SYSVAR_ULONG(io_capacity, srv_io_capacity,
...
@@ -10982,16 +10982,23 @@ static MYSQL_SYSVAR_ULONG(io_capacity, srv_io_capacity,
static
MYSQL_SYSVAR_ULONG
(
purge_batch_size
,
srv_purge_batch_size
,
static
MYSQL_SYSVAR_ULONG
(
purge_batch_size
,
srv_purge_batch_size
,
PLUGIN_VAR_OPCMDARG
,
PLUGIN_VAR_OPCMDARG
,
"Number of UNDO logs to purge in one batch from the history list. "
"Number of UNDO log pages to purge in one batch from the history list."
,
"Default is 20"
,
NULL
,
NULL
,
NULL
,
NULL
,
20
,
/* Default setting */
20
,
/* Default setting */
1
,
/* Minimum value */
1
,
/* Minimum value */
5000
,
0
);
/* Maximum value */
5000
,
0
);
/* Maximum value */
static
MYSQL_SYSVAR_ULONG
(
rollback_segments
,
srv_rollback_segments
,
PLUGIN_VAR_OPCMDARG
,
"Number of UNDO logs to use."
,
NULL
,
NULL
,
128
,
/* Default setting */
1
,
/* Minimum value */
TRX_SYS_N_RSEGS
,
0
);
/* Maximum value */
static
MYSQL_SYSVAR_ULONG
(
purge_threads
,
srv_n_purge_threads
,
static
MYSQL_SYSVAR_ULONG
(
purge_threads
,
srv_n_purge_threads
,
PLUGIN_VAR_OPCMDARG
|
PLUGIN_VAR_READONLY
,
PLUGIN_VAR_OPCMDARG
|
PLUGIN_VAR_READONLY
,
"Purge threads can be either 0 or 1.
Default is 0.
"
,
"Purge threads can be either 0 or 1."
,
NULL
,
NULL
,
NULL
,
NULL
,
0
,
/* Default setting */
0
,
/* Default setting */
0
,
/* Minimum value */
0
,
/* Minimum value */
...
@@ -11342,6 +11349,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
...
@@ -11342,6 +11349,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR
(
io_capacity
),
MYSQL_SYSVAR
(
io_capacity
),
MYSQL_SYSVAR
(
purge_threads
),
MYSQL_SYSVAR
(
purge_threads
),
MYSQL_SYSVAR
(
purge_batch_size
),
MYSQL_SYSVAR
(
purge_batch_size
),
MYSQL_SYSVAR
(
rollback_segments
),
NULL
NULL
};
};
...
...
storage/innobase/include/buf0flu.h
View file @
19372f10
...
@@ -138,7 +138,18 @@ UNIV_INTERN
...
@@ -138,7 +138,18 @@ UNIV_INTERN
void
void
buf_flush_wait_batch_end
(
buf_flush_wait_batch_end
(
/*=====================*/
/*=====================*/
buf_pool_t
*
buf_pool
,
/*!< buffer pool instance */
buf_pool_t
*
buf_pool
,
/*!< in: buffer pool instance */
enum
buf_flush
type
);
/*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */
/******************************************************************//**
Waits until a flush batch of the given type ends. This is called by
a thread that only wants to wait for a flush to end but doesn't do
any flushing itself. */
UNIV_INTERN
void
buf_flush_wait_batch_end_wait_only
(
/*===============================*/
buf_pool_t
*
buf_pool
,
/*!< in: buffer pool instance */
enum
buf_flush
type
);
/*!< in: BUF_FLUSH_LRU
enum
buf_flush
type
);
/*!< in: BUF_FLUSH_LRU
or BUF_FLUSH_LIST */
or BUF_FLUSH_LIST */
/********************************************************************//**
/********************************************************************//**
...
...
storage/innobase/include/srv0srv.h
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1995, 201
0
, Innobase Oy. All Rights Reserved.
Copyright (c) 1995, 201
1
, Innobase Oy. All Rights Reserved.
Copyright (c) 2008, 2009, Google Inc.
Copyright (c) 2008, 2009, Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2009, Percona Inc.
...
@@ -294,9 +294,12 @@ extern ulint srv_log_waits;
...
@@ -294,9 +294,12 @@ extern ulint srv_log_waits;
/* the number of purge threads to use from the worker pool (currently 0 or 1) */
/* the number of purge threads to use from the worker pool (currently 0 or 1) */
extern
ulong
srv_n_purge_threads
;
extern
ulong
srv_n_purge_threads
;
/* the number of
record
s to purge in one batch */
/* the number of
page
s to purge in one batch */
extern
ulong
srv_purge_batch_size
;
extern
ulong
srv_purge_batch_size
;
/* the number of rollback segments to use */
extern
ulong
srv_rollback_segments
;
/* variable that counts amount of data read in total (in bytes) */
/* variable that counts amount of data read in total (in bytes) */
extern
ulint
srv_data_read
;
extern
ulint
srv_data_read
;
...
...
storage/innobase/include/sync0sync.h
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1995, 201
0
, Innobase Oy. All Rights Reserved.
Copyright (c) 1995, 201
1
, Innobase Oy. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
Portions of this file contain modifications contributed and copyrighted by
...
@@ -93,7 +93,7 @@ extern mysql_pfs_key_t mem_hash_mutex_key;
...
@@ -93,7 +93,7 @@ extern mysql_pfs_key_t mem_hash_mutex_key;
# endif
/* UNIV_MEM_DEBUG */
# endif
/* UNIV_MEM_DEBUG */
extern
mysql_pfs_key_t
mem_pool_mutex_key
;
extern
mysql_pfs_key_t
mem_pool_mutex_key
;
extern
mysql_pfs_key_t
mutex_list_mutex_key
;
extern
mysql_pfs_key_t
mutex_list_mutex_key
;
extern
mysql_pfs_key_t
purge_sys_mutex_key
;
extern
mysql_pfs_key_t
purge_sys_
bh_
mutex_key
;
extern
mysql_pfs_key_t
recv_sys_mutex_key
;
extern
mysql_pfs_key_t
recv_sys_mutex_key
;
extern
mysql_pfs_key_t
rseg_mutex_key
;
extern
mysql_pfs_key_t
rseg_mutex_key
;
# ifdef UNIV_SYNC_DEBUG
# ifdef UNIV_SYNC_DEBUG
...
@@ -637,7 +637,6 @@ or row lock! */
...
@@ -637,7 +637,6 @@ or row lock! */
#define SYNC_TREE_NODE_NEW 892
#define SYNC_TREE_NODE_NEW 892
#define SYNC_TREE_NODE_FROM_HASH 891
#define SYNC_TREE_NODE_FROM_HASH 891
#define SYNC_TREE_NODE 890
#define SYNC_TREE_NODE 890
#define SYNC_PURGE_SYS 810
#define SYNC_PURGE_LATCH 800
#define SYNC_PURGE_LATCH 800
#define SYNC_TRX_UNDO 700
#define SYNC_TRX_UNDO 700
#define SYNC_RSEG 600
#define SYNC_RSEG 600
...
@@ -659,6 +658,7 @@ or row lock! */
...
@@ -659,6 +658,7 @@ or row lock! */
#define SYNC_REC_LOCK 299
#define SYNC_REC_LOCK 299
#define SYNC_TRX_LOCK_HEAP 298
#define SYNC_TRX_LOCK_HEAP 298
#define SYNC_TRX_SYS_HEADER 290
#define SYNC_TRX_SYS_HEADER 290
#define SYNC_PURGE_QUEUE 200
#define SYNC_LOG 170
#define SYNC_LOG 170
#define SYNC_LOG_FLUSH_ORDER 147
#define SYNC_LOG_FLUSH_ORDER 147
#define SYNC_RECV 168
#define SYNC_RECV 168
...
...
storage/innobase/include/trx0purge.h
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1996, 20
09
, Innobase Oy. All Rights Reserved.
Copyright (c) 1996, 20
11
, Innobase Oy. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
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
the terms of the GNU General Public License as published by the Free Software
...
@@ -68,8 +68,9 @@ Creates the global purge system control structure and inits the history
...
@@ -68,8 +68,9 @@ Creates the global purge system control structure and inits the history
mutex. */
mutex. */
UNIV_INTERN
UNIV_INTERN
void
void
trx_purge_sys_create
(
void
);
trx_purge_sys_create
(
/*======================*/
/*=================*/
ib_bh_t
*
ib_bh
);
/*!< in/own: UNDO log min binary heap*/
/********************************************************************//**
/********************************************************************//**
Frees the global purge system control structure. */
Frees the global purge system control structure. */
UNIV_INTERN
UNIV_INTERN
...
@@ -128,20 +129,20 @@ struct trx_purge_struct{
...
@@ -128,20 +129,20 @@ struct trx_purge_struct{
ulint
state
;
/*!< Purge system state */
ulint
state
;
/*!< Purge system state */
sess_t
*
sess
;
/*!< System session running the purge
sess_t
*
sess
;
/*!< System session running the purge
query */
query */
trx_t
*
trx
;
/*!< System transaction running the purge
trx_t
*
trx
;
/*!< System transaction running the
purge
query: this trx is not in the trx list
query: this trx is not in the trx list
of the trx system and it never ends */
of the trx system and it never ends */
que_t
*
query
;
/*!< The query graph which will do the
que_t
*
query
;
/*!< The query graph which will do the
parallelized purge operation */
parallelized purge operation */
rw_lock_t
latch
;
/*!< The latch protecting the purge
view.
rw_lock_t
latch
;
/*!< The latch protecting the purge
A purge operation must acquire an
view. A purge operation must acquire
x-latch here for the instant at which
an
x-latch here for the instant at which
it changes the purge view: an undo
it changes the purge view: an undo
log operation can prevent this by
log operation can prevent this by
obtaining an s-latch here. */
obtaining an s-latch here. */
read_view_t
*
view
;
/*!< The purge will not remove undo logs
read_view_t
*
view
;
/*!< The purge will not remove undo logs
which are >= this view (purge view) */
which are >= this view (purge view) */
mutex_t
mutex
;
/*!< Mutex protecting the fields below */
ulint
n_pages_handled
;
/*!< Approximate number of undo log
ulint
n_pages_handled
;
/*!< Approximate number of undo log
pages processed in purge */
pages processed in purge */
ulint
handle_limit
;
/*!< Target of how many pages to get
ulint
handle_limit
;
/*!< Target of how many pages to get
...
@@ -179,6 +180,11 @@ struct trx_purge_struct{
...
@@ -179,6 +180,11 @@ struct trx_purge_struct{
mem_heap_t
*
heap
;
/*!< Temporary storage used during a
mem_heap_t
*
heap
;
/*!< Temporary storage used during a
purge: can be emptied after purge
purge: can be emptied after purge
completes */
completes */
/*-----------------------------*/
ib_bh_t
*
ib_bh
;
/*!< Binary min-heap, ordered on
rseg_queue_t::trx_no. It is protected
by the bh_mutex */
mutex_t
bh_mutex
;
/*!< Mutex protecting ib_bh */
};
};
#define TRX_PURGE_ON 1
/* purge operation is running */
#define TRX_PURGE_ON 1
/* purge operation is running */
...
...
storage/innobase/include/trx0rseg.h
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1996, 201
0
, Innobase Oy. All Rights Reserved.
Copyright (c) 1996, 201
1
, Innobase Oy. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
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
the terms of the GNU General Public License as published by the Free Software
...
@@ -113,7 +113,9 @@ void
...
@@ -113,7 +113,9 @@ void
trx_rseg_list_and_array_init
(
trx_rseg_list_and_array_init
(
/*=========================*/
/*=========================*/
trx_sysf_t
*
sys_header
,
/*!< in: trx system header */
trx_sysf_t
*
sys_header
,
/*!< in: trx system header */
ib_bh_t
*
ib_bh
,
/*!< in: rseg queue */
mtr_t
*
mtr
);
/*!< in: mtr */
mtr_t
*
mtr
);
/*!< in: mtr */
/***************************************************************************
/***************************************************************************
Free's an instance of the rollback segment in memory. */
Free's an instance of the rollback segment in memory. */
UNIV_INTERN
UNIV_INTERN
...
@@ -180,6 +182,14 @@ struct trx_rseg_struct{
...
@@ -180,6 +182,14 @@ struct trx_rseg_struct{
memory objects */
memory objects */
};
};
/** For prioritising the rollback segments for purge. */
struct
rseg_queue_struct
{
trx_id_t
trx_no
;
/*!< trx_rseg_t::last_trx_no */
trx_rseg_t
*
rseg
;
/*!< Rollback segment */
};
typedef
struct
rseg_queue_struct
rseg_queue_t
;
/* Undo log segment slot in a rollback segment header */
/* Undo log segment slot in a rollback segment header */
/*-------------------------------------------------------------*/
/*-------------------------------------------------------------*/
#define TRX_RSEG_SLOT_PAGE_NO 0
/* Page number of the header page of
#define TRX_RSEG_SLOT_PAGE_NO 0
/* Page number of the header page of
...
...
storage/innobase/include/trx0sys.h
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1996, 201
0
, Innobase Oy. All Rights Reserved.
Copyright (c) 1996, 201
1
, Innobase Oy. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
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
the terms of the GNU General Public License as published by the Free Software
...
@@ -38,6 +38,7 @@ Created 3/26/1996 Heikki Tuuri
...
@@ -38,6 +38,7 @@ Created 3/26/1996 Heikki Tuuri
#include "mem0mem.h"
#include "mem0mem.h"
#include "sync0sync.h"
#include "sync0sync.h"
#include "ut0lst.h"
#include "ut0lst.h"
#include "ut0bh.h"
#include "read0types.h"
#include "read0types.h"
#include "page0types.h"
#include "page0types.h"
...
@@ -221,13 +222,6 @@ UNIV_INLINE
...
@@ -221,13 +222,6 @@ UNIV_INLINE
trx_id_t
trx_id_t
trx_sys_get_new_trx_id
(
void
);
trx_sys_get_new_trx_id
(
void
);
/*========================*/
/*========================*/
/*****************************************************************//**
Allocates a new transaction number.
@return new, allocated trx number */
UNIV_INLINE
trx_id_t
trx_sys_get_new_trx_no
(
void
);
/*========================*/
#endif
/* !UNIV_HOTBACKUP */
#endif
/* !UNIV_HOTBACKUP */
/*****************************************************************//**
/*****************************************************************//**
Writes a trx id to an index page. In case that the id size changes in
Writes a trx id to an index page. In case that the id size changes in
...
...
storage/innobase/include/trx0sys.ic
View file @
19372f10
...
@@ -369,16 +369,4 @@ trx_sys_get_new_trx_id(void)
...
@@ -369,16 +369,4 @@ trx_sys_get_new_trx_id(void)
return(id);
return(id);
}
}
/*****************************************************************//**
Allocates a new transaction number.
@return new, allocated trx number */
UNIV_INLINE
trx_id_t
trx_sys_get_new_trx_no(void)
/*========================*/
{
ut_ad(mutex_own(&kernel_mutex));
return(trx_sys_get_new_trx_id());
}
#endif /* !UNIV_HOTBACKUP */
#endif /* !UNIV_HOTBACKUP */
storage/innobase/include/ut0bh.h
0 → 100644
View file @
19372f10
/***************************************************************************//**
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.h
Binary min-heap interface.
Created 2010-05-28 by Sunny Bains
*******************************************************/
#ifndef INNOBASE_UT0BH_H
#define INNOBASE_UT0BH_H
#include "univ.i"
/** Comparison function for objects in the binary heap. */
typedef
int
(
*
ib_bh_cmp_t
)(
const
void
*
p1
,
const
void
*
p2
);
typedef
struct
ib_bh_struct
ib_bh_t
;
/**********************************************************************//**
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 */
/**********************************************************************//**
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 */
/**********************************************************************//**
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 */
/**********************************************************************//**
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 */
/**********************************************************************//**
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 */
/**********************************************************************//**
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 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 */
/**********************************************************************//**
Create a binary heap.
@return a new binary heap */
UNIV_INTERN
ib_bh_t
*
ib_bh_create
(
/*=========*/
ib_bh_cmp_t
compare
,
/*!< in: comparator */
ulint
sizeof_elem
,
/*!< in: size of one element */
ulint
max_elems
);
/*!< in: max elements allowed */
/**********************************************************************//**
Free a binary heap.
@return a new binary heap */
UNIV_INTERN
void
ib_bh_free
(
/*=======*/
ib_bh_t
*
ib_bh
);
/*!< in,own: instance */
/**********************************************************************//**
Add an element to the binary heap. Note: The element is copied.
@return pointer to added element or NULL if full. */
UNIV_INTERN
void
*
ib_bh_push
(
/*=======*/
ib_bh_t
*
ib_bh
,
/*!< in/out: instance */
const
void
*
elem
);
/*!< in: element to add */
/**********************************************************************//**
Remove the first element from the binary heap. */
UNIV_INTERN
void
ib_bh_pop
(
/*======*/
ib_bh_t
*
ib_bh
);
/*!< in/out: instance */
/** Binary heap data structure */
struct
ib_bh_struct
{
ulint
max_elems
;
/*!< max elements allowed */
ulint
n_elems
;
/*!< current size */
ulint
sizeof_elem
;
/*!< sizeof element */
ib_bh_cmp_t
compare
;
/*!< comparator */
};
#ifndef UNIV_NONINL
#include "ut0bh.ic"
#endif
#endif
/* INNOBASE_UT0BH_H */
storage/innobase/include/ut0bh.ic
0 → 100644
View file @
19372f10
/***************************************************************************//**
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"
#include "ut0mem.h" /* For ut_memcpy() */
/**********************************************************************//**
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));
}
storage/innobase/srv/srv0srv.c
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1995, 201
0, Innobase Oy
. All Rights Reserved.
Copyright (c) 1995, 201
1, Oracle and/or its affiliates
. All Rights Reserved.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2008, 2009 Google Inc.
Copyright (c) 2009, Percona Inc.
Copyright (c) 2009, Percona Inc.
...
@@ -269,9 +269,12 @@ UNIV_INTERN ulong srv_max_buf_pool_modified_pct = 75;
...
@@ -269,9 +269,12 @@ UNIV_INTERN ulong srv_max_buf_pool_modified_pct = 75;
/* the number of purge threads to use from the worker pool (currently 0 or 1).*/
/* the number of purge threads to use from the worker pool (currently 0 or 1).*/
UNIV_INTERN
ulong
srv_n_purge_threads
=
0
;
UNIV_INTERN
ulong
srv_n_purge_threads
=
0
;
/* the number of
record
s to purge in one batch */
/* the number of
page
s to purge in one batch */
UNIV_INTERN
ulong
srv_purge_batch_size
=
20
;
UNIV_INTERN
ulong
srv_purge_batch_size
=
20
;
/* the number of rollback segments to use */
UNIV_INTERN
ulong
srv_rollback_segments
=
TRX_SYS_N_RSEGS
;
/* variable counts amount of data read in total (in bytes) */
/* variable counts amount of data read in total (in bytes) */
UNIV_INTERN
ulint
srv_data_read
=
0
;
UNIV_INTERN
ulint
srv_data_read
=
0
;
...
@@ -3096,6 +3099,7 @@ srv_purge_thread(
...
@@ -3096,6 +3099,7 @@ srv_purge_thread(
required by os_thread_create */
required by os_thread_create */
{
{
srv_slot_t
*
slot
;
srv_slot_t
*
slot
;
ulint
retries
=
0
;
ulint
slot_no
=
ULINT_UNDEFINED
;
ulint
slot_no
=
ULINT_UNDEFINED
;
ulint
n_total_purged
=
ULINT_UNDEFINED
;
ulint
n_total_purged
=
ULINT_UNDEFINED
;
...
@@ -3122,7 +3126,7 @@ srv_purge_thread(
...
@@ -3122,7 +3126,7 @@ srv_purge_thread(
while
(
srv_shutdown_state
!=
SRV_SHUTDOWN_EXIT_THREADS
)
{
while
(
srv_shutdown_state
!=
SRV_SHUTDOWN_EXIT_THREADS
)
{
ulint
n_pages_purged
;
ulint
n_pages_purged
=
0
;
/* If there are very few records to purge or the last
/* If there are very few records to purge or the last
purge didn't purge any records then wait for activity.
purge didn't purge any records then wait for activity.
...
@@ -3130,7 +3134,8 @@ srv_purge_thread(
...
@@ -3130,7 +3134,8 @@ srv_purge_thread(
because in the worst case we will end up waiting for
because in the worst case we will end up waiting for
the next purge event. */
the next purge event. */
if
(
trx_sys
->
rseg_history_len
<
srv_purge_batch_size
if
(
trx_sys
->
rseg_history_len
<
srv_purge_batch_size
||
n_total_purged
==
0
)
{
||
(
n_total_purged
==
0
&&
retries
>=
TRX_SYS_N_RSEGS
))
{
os_event_t
event
;
os_event_t
event
;
...
@@ -3141,6 +3146,8 @@ srv_purge_thread(
...
@@ -3141,6 +3146,8 @@ srv_purge_thread(
mutex_exit
(
&
kernel_mutex
);
mutex_exit
(
&
kernel_mutex
);
os_event_wait
(
event
);
os_event_wait
(
event
);
retries
=
0
;
}
}
/* Check for shutdown and whether we should do purge at all. */
/* Check for shutdown and whether we should do purge at all. */
...
@@ -3151,7 +3158,12 @@ srv_purge_thread(
...
@@ -3151,7 +3158,12 @@ srv_purge_thread(
break
;
break
;
}
}
n_total_purged
=
0
;
if
(
n_total_purged
==
0
&&
retries
<=
TRX_SYS_N_RSEGS
)
{
++
retries
;
}
else
if
(
n_total_purged
>
0
)
{
retries
=
0
;
n_total_purged
=
0
;
}
/* Purge until there are no more records to purge and there is
/* Purge until there are no more records to purge and there is
no change in configuration or server state. */
no change in configuration or server state. */
...
...
storage/innobase/sync/sync0sync.c
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1995, 201
0
, Innobase Oy. All Rights Reserved.
Copyright (c) 1995, 201
1
, Innobase Oy. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2008, Google Inc.
Portions of this file contain modifications contributed and copyrighted by
Portions of this file contain modifications contributed and copyrighted by
...
@@ -1172,7 +1172,7 @@ sync_thread_add_level(
...
@@ -1172,7 +1172,7 @@ sync_thread_add_level(
case
SYNC_RSEG
:
case
SYNC_RSEG
:
case
SYNC_TRX_UNDO
:
case
SYNC_TRX_UNDO
:
case
SYNC_PURGE_LATCH
:
case
SYNC_PURGE_LATCH
:
case
SYNC_PURGE_
SYS
:
case
SYNC_PURGE_
QUEUE
:
case
SYNC_DICT_AUTOINC_MUTEX
:
case
SYNC_DICT_AUTOINC_MUTEX
:
case
SYNC_DICT_OPERATION
:
case
SYNC_DICT_OPERATION
:
case
SYNC_DICT_HEADER
:
case
SYNC_DICT_HEADER
:
...
@@ -1239,10 +1239,16 @@ sync_thread_add_level(
...
@@ -1239,10 +1239,16 @@ sync_thread_add_level(
||
sync_thread_levels_g
(
array
,
SYNC_FSP
,
TRUE
));
||
sync_thread_levels_g
(
array
,
SYNC_FSP
,
TRUE
));
break
;
break
;
case
SYNC_TRX_UNDO_PAGE
:
case
SYNC_TRX_UNDO_PAGE
:
/* Purge is allowed to read in as many UNDO pages as it likes,
there was a bogus rule here earlier that forced the caller to
acquire the purge_sys_t::mutex. The purge mutex did not really
protect anything because it was only ever acquired by the
single purge thread. The purge thread can read the UNDO pages
without any covering mutex. */
ut_a
(
sync_thread_levels_contain
(
array
,
SYNC_TRX_UNDO
)
ut_a
(
sync_thread_levels_contain
(
array
,
SYNC_TRX_UNDO
)
||
sync_thread_levels_contain
(
array
,
SYNC_RSEG
)
||
sync_thread_levels_contain
(
array
,
SYNC_RSEG
)
||
sync_thread_levels_contain
(
array
,
SYNC_PURGE_SYS
)
||
sync_thread_levels_g
(
array
,
level
-
1
,
TRUE
));
||
sync_thread_levels_g
(
array
,
SYNC_TRX_UNDO_PAGE
,
TRUE
));
break
;
break
;
case
SYNC_RSEG_HEADER
:
case
SYNC_RSEG_HEADER
:
ut_a
(
sync_thread_levels_contain
(
array
,
SYNC_RSEG
));
ut_a
(
sync_thread_levels_contain
(
array
,
SYNC_RSEG
));
...
...
storage/innobase/trx/trx0purge.c
View file @
19372f10
This diff is collapsed.
Click to expand it.
storage/innobase/trx/trx0rseg.c
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1996, 201
0, Innobase Oy
. All Rights Reserved.
Copyright (c) 1996, 201
1, Oracle Corpn
. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
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
the terms of the GNU General Public License as published by the Free Software
...
@@ -50,11 +50,11 @@ trx_rseg_get_on_id(
...
@@ -50,11 +50,11 @@ trx_rseg_get_on_id(
{
{
trx_rseg_t
*
rseg
;
trx_rseg_t
*
rseg
;
rseg
=
UT_LIST_GET_FIRST
(
trx_sys
->
rseg_list
);
ut_a
(
id
<
TRX_SYS_N_RSEGS
);
while
(
rseg
&&
rseg
->
id
!=
id
)
{
rseg
=
trx_sys
->
rseg_array
[
id
];
rseg
=
UT_LIST_GET_NEXT
(
rseg_list
,
rseg
);
}
ut_a
(
rseg
==
NULL
||
id
==
rseg
->
id
);
return
(
rseg
);
return
(
rseg
);
}
}
...
@@ -181,12 +181,15 @@ static
...
@@ -181,12 +181,15 @@ static
trx_rseg_t
*
trx_rseg_t
*
trx_rseg_mem_create
(
trx_rseg_mem_create
(
/*================*/
/*================*/
ulint
id
,
/*!< in: rollback segment id */
ulint
id
,
/*!< in: rollback segment id */
ulint
space
,
/*!< in: space where the segment placed */
ulint
space
,
/*!< in: space where the segment
ulint
zip_size
,
/*!< in: compressed page size in bytes
placed */
or 0 for uncompressed pages */
ulint
zip_size
,
/*!< in: compressed page size in bytes
ulint
page_no
,
/*!< in: page number of the segment header */
or 0 for uncompressed pages */
mtr_t
*
mtr
)
/*!< in: mtr */
ulint
page_no
,
/*!< in: page number of the segment
header */
ib_bh_t
*
ib_bh
,
/*!< in/out: rseg queue */
mtr_t
*
mtr
)
/*!< in: mtr */
{
{
ulint
len
;
ulint
len
;
trx_rseg_t
*
rseg
;
trx_rseg_t
*
rseg
;
...
@@ -225,6 +228,9 @@ trx_rseg_mem_create(
...
@@ -225,6 +228,9 @@ trx_rseg_mem_create(
len
=
flst_get_len
(
rseg_header
+
TRX_RSEG_HISTORY
,
mtr
);
len
=
flst_get_len
(
rseg_header
+
TRX_RSEG_HISTORY
,
mtr
);
if
(
len
>
0
)
{
if
(
len
>
0
)
{
const
void
*
ptr
;
rseg_queue_t
rseg_queue
;
trx_sys
->
rseg_history_len
+=
len
;
trx_sys
->
rseg_history_len
+=
len
;
node_addr
=
trx_purge_get_log_from_hist
(
node_addr
=
trx_purge_get_log_from_hist
(
...
@@ -240,6 +246,17 @@ trx_rseg_mem_create(
...
@@ -240,6 +246,17 @@ trx_rseg_mem_create(
undo_log_hdr
+
TRX_UNDO_TRX_NO
);
undo_log_hdr
+
TRX_UNDO_TRX_NO
);
rseg
->
last_del_marks
=
mtr_read_ulint
(
rseg
->
last_del_marks
=
mtr_read_ulint
(
undo_log_hdr
+
TRX_UNDO_DEL_MARKS
,
MLOG_2BYTES
,
mtr
);
undo_log_hdr
+
TRX_UNDO_DEL_MARKS
,
MLOG_2BYTES
,
mtr
);
rseg_queue
.
rseg
=
rseg
;
rseg_queue
.
trx_no
=
rseg
->
last_trx_no
;
if
(
rseg
->
last_page_no
!=
FIL_NULL
)
{
/* There is no need to cover this operation by the purge
mutex because we are still bootstrapping. */
ptr
=
ib_bh_push
(
ib_bh
,
&
rseg_queue
);
ut_a
(
ptr
!=
NULL
);
}
}
else
{
}
else
{
rseg
->
last_page_no
=
FIL_NULL
;
rseg
->
last_page_no
=
FIL_NULL
;
}
}
...
@@ -255,6 +272,7 @@ void
...
@@ -255,6 +272,7 @@ void
trx_rseg_create_instance
(
trx_rseg_create_instance
(
/*=====================*/
/*=====================*/
trx_sysf_t
*
sys_header
,
/*!< in: trx system header */
trx_sysf_t
*
sys_header
,
/*!< in: trx system header */
ib_bh_t
*
ib_bh
,
/*!< in/out: rseg queue */
mtr_t
*
mtr
)
/*!< in: mtr */
mtr_t
*
mtr
)
/*!< in: mtr */
{
{
ulint
i
;
ulint
i
;
...
@@ -278,7 +296,7 @@ trx_rseg_create_instance(
...
@@ -278,7 +296,7 @@ trx_rseg_create_instance(
zip_size
=
space
?
fil_space_get_zip_size
(
space
)
:
0
;
zip_size
=
space
?
fil_space_get_zip_size
(
space
)
:
0
;
rseg
=
trx_rseg_mem_create
(
rseg
=
trx_rseg_mem_create
(
i
,
space
,
zip_size
,
page_no
,
mtr
);
i
,
space
,
zip_size
,
page_no
,
ib_bh
,
mtr
);
ut_a
(
rseg
->
id
==
i
);
ut_a
(
rseg
->
id
==
i
);
}
}
...
@@ -327,7 +345,8 @@ trx_rseg_create(void)
...
@@ -327,7 +345,8 @@ trx_rseg_create(void)
zip_size
=
space
?
fil_space_get_zip_size
(
space
)
:
0
;
zip_size
=
space
?
fil_space_get_zip_size
(
space
)
:
0
;
rseg
=
trx_rseg_mem_create
(
rseg
=
trx_rseg_mem_create
(
slot_no
,
space
,
zip_size
,
page_no
,
&
mtr
);
slot_no
,
space
,
zip_size
,
page_no
,
purge_sys
->
ib_bh
,
&
mtr
);
}
}
mutex_exit
(
&
kernel_mutex
);
mutex_exit
(
&
kernel_mutex
);
...
@@ -342,13 +361,14 @@ UNIV_INTERN
...
@@ -342,13 +361,14 @@ UNIV_INTERN
void
void
trx_rseg_list_and_array_init
(
trx_rseg_list_and_array_init
(
/*=========================*/
/*=========================*/
trx_sysf_t
*
sys_header
,
/* in: trx system header */
trx_sysf_t
*
sys_header
,
/*!< in: trx system header */
mtr_t
*
mtr
)
/* in: mtr */
ib_bh_t
*
ib_bh
,
/*!< in: rseg queue */
mtr_t
*
mtr
)
/*!< in: mtr */
{
{
UT_LIST_INIT
(
trx_sys
->
rseg_list
);
UT_LIST_INIT
(
trx_sys
->
rseg_list
);
trx_sys
->
rseg_history_len
=
0
;
trx_sys
->
rseg_history_len
=
0
;
trx_rseg_create_instance
(
sys_header
,
mtr
);
trx_rseg_create_instance
(
sys_header
,
ib_bh
,
mtr
);
}
}
storage/innobase/trx/trx0sys.c
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1996, 201
0
, Innobase Oy. All Rights Reserved.
Copyright (c) 1996, 201
1
, Innobase Oy. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
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
the terms of the GNU General Public License as published by the Free Software
...
@@ -945,6 +945,31 @@ trx_sysf_create(
...
@@ -945,6 +945,31 @@ trx_sysf_create(
mutex_exit
(
&
kernel_mutex
);
mutex_exit
(
&
kernel_mutex
);
}
}
/*****************************************************************//**
Compare two trx_rseg_t instances on last_trx_no. */
static
int
trx_rseg_compare_last_trx_no
(
/*=========================*/
const
void
*
p1
,
/*!< in: elem to compare */
const
void
*
p2
)
/*!< in: elem to compare */
{
ib_int64_t
cmp
;
const
rseg_queue_t
*
rseg_q1
=
(
const
rseg_queue_t
*
)
p1
;
const
rseg_queue_t
*
rseg_q2
=
(
const
rseg_queue_t
*
)
p2
;
cmp
=
rseg_q1
->
trx_no
-
rseg_q2
->
trx_no
;
if
(
cmp
<
0
)
{
return
(
-
1
);
}
else
if
(
cmp
>
0
)
{
return
(
1
);
}
return
(
0
);
}
/*****************************************************************//**
/*****************************************************************//**
Creates and initializes the central memory structures for the transaction
Creates and initializes the central memory structures for the transaction
system. This is called when the database is started. */
system. This is called when the database is started. */
...
@@ -958,6 +983,7 @@ trx_sys_init_at_db_start(void)
...
@@ -958,6 +983,7 @@ trx_sys_init_at_db_start(void)
const
char
*
unit
=
""
;
const
char
*
unit
=
""
;
trx_t
*
trx
;
trx_t
*
trx
;
mtr_t
mtr
;
mtr_t
mtr
;
ib_bh_t
*
ib_bh
;
mtr_start
(
&
mtr
);
mtr_start
(
&
mtr
);
...
@@ -965,11 +991,19 @@ trx_sys_init_at_db_start(void)
...
@@ -965,11 +991,19 @@ trx_sys_init_at_db_start(void)
mutex_enter
(
&
kernel_mutex
);
mutex_enter
(
&
kernel_mutex
);
trx_sys
=
mem_alloc
(
sizeof
(
trx_sys_t
));
/* We create the min binary heap here and pass ownership to
purge when we init the purge sub-system. Purge is responsible
for freeing the binary heap. */
ib_bh
=
ib_bh_create
(
trx_rseg_compare_last_trx_no
,
sizeof
(
rseg_queue_t
),
TRX_SYS_N_RSEGS
);
trx_sys
=
mem_zalloc
(
sizeof
(
*
trx_sys
));
sys_header
=
trx_sysf_get
(
&
mtr
);
sys_header
=
trx_sysf_get
(
&
mtr
);
trx_rseg_list_and_array_init
(
sys_header
,
&
mtr
);
trx_rseg_list_and_array_init
(
sys_header
,
ib_bh
,
&
mtr
);
trx_sys
->
latest_rseg
=
UT_LIST_GET_FIRST
(
trx_sys
->
rseg_list
);
trx_sys
->
latest_rseg
=
UT_LIST_GET_FIRST
(
trx_sys
->
rseg_list
);
...
@@ -1023,7 +1057,8 @@ trx_sys_init_at_db_start(void)
...
@@ -1023,7 +1057,8 @@ trx_sys_init_at_db_start(void)
UT_LIST_INIT
(
trx_sys
->
view_list
);
UT_LIST_INIT
(
trx_sys
->
view_list
);
trx_purge_sys_create
();
/* Transfer ownership to purge. */
trx_purge_sys_create
(
ib_bh
);
mutex_exit
(
&
kernel_mutex
);
mutex_exit
(
&
kernel_mutex
);
...
...
storage/innobase/trx/trx0trx.c
View file @
19372f10
This diff is collapsed.
Click to expand it.
storage/innobase/ut/ut0bh.c
0 → 100644
View file @
19372f10
/***************************************************************************//**
Copyright (c) 2010, 2011, Oracle Corpn. All Rights Reserved.
Portions of this file contain modifications contributed and copyrighted by
Sun Microsystems, Inc. Those modifications are gratefully acknowledged and
are described briefly in the InnoDB documentation. The contributions by
Sun Microsystems are incorporated with their permission, and subject to the
conditions contained in the file COPYING.Sun_Microsystems.
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 ut/ut0bh.c
Binary min-heap implementation.
Created 2010-05-28 by Sunny Bains
*******************************************************/
#include "ut0bh.h"
#include "ut0mem.h"
#ifdef UNIV_NONINL
#include "ut0bh.ic"
#endif
#include <string.h>
/**********************************************************************//**
Create a binary heap.
@return a new binary heap */
UNIV_INTERN
ib_bh_t
*
ib_bh_create
(
/*=========*/
ib_bh_cmp_t
compare
,
/*!< in: comparator */
ulint
sizeof_elem
,
/*!< in: size of one element */
ulint
max_elems
)
/*!< in: max elements allowed */
{
ulint
sz
;
ib_bh_t
*
ib_bh
;
sz
=
sizeof
(
*
ib_bh
)
+
(
sizeof_elem
*
max_elems
);
ib_bh
=
(
ib_bh_t
*
)
ut_malloc
(
sz
);
memset
(
ib_bh
,
0x0
,
sz
);
ib_bh
->
compare
=
compare
;
ib_bh
->
max_elems
=
max_elems
;
ib_bh
->
sizeof_elem
=
sizeof_elem
;
return
(
ib_bh
);
}
/**********************************************************************//**
Free a binary heap.
@return a new binary heap */
UNIV_INTERN
void
ib_bh_free
(
/*=======*/
ib_bh_t
*
ib_bh
)
/*!< in/own: instance */
{
ut_free
(
ib_bh
);
}
/**********************************************************************//**
Add an element to the binary heap. Note: The element is copied.
@return pointer to added element or NULL if full. */
UNIV_INTERN
void
*
ib_bh_push
(
/*=======*/
ib_bh_t
*
ib_bh
,
/*!< in/out: instance */
const
void
*
elem
)
/*!< in: element to add */
{
void
*
ptr
;
if
(
ib_bh_is_full
(
ib_bh
))
{
return
(
NULL
);
}
else
if
(
ib_bh_is_empty
(
ib_bh
))
{
++
ib_bh
->
n_elems
;
return
(
ib_bh_set
(
ib_bh
,
0
,
elem
));
}
else
{
ulint
i
;
i
=
ib_bh
->
n_elems
;
++
ib_bh
->
n_elems
;
for
(
ptr
=
ib_bh_get
(
ib_bh
,
i
>>
1
);
i
>
0
&&
ib_bh
->
compare
(
ptr
,
elem
)
>
0
;
i
>>=
1
,
ptr
=
ib_bh_get
(
ib_bh
,
i
>>
1
))
{
ib_bh_set
(
ib_bh
,
i
,
ptr
);
}
ptr
=
ib_bh_set
(
ib_bh
,
i
,
elem
);
}
return
(
ptr
);
}
/**********************************************************************//**
Remove the first element from the binary heap. */
UNIV_INTERN
void
ib_bh_pop
(
/*======*/
ib_bh_t
*
ib_bh
)
/*!< in/out: instance */
{
byte
*
ptr
;
byte
*
last
;
ulint
parent
=
0
;
if
(
ib_bh_is_empty
(
ib_bh
))
{
return
;
}
else
if
(
ib_bh_size
(
ib_bh
)
==
1
)
{
--
ib_bh
->
n_elems
;
return
;
}
last
=
(
byte
*
)
ib_bh_last
(
ib_bh
);
/* Start from the child node */
ptr
=
(
byte
*
)
ib_bh_get
(
ib_bh
,
1
);
while
(
ptr
<
last
)
{
/* If the "right" child node is < "left" child node */
if
(
ib_bh
->
compare
(
ptr
+
ib_bh
->
sizeof_elem
,
ptr
)
<
0
)
{
ptr
+=
ib_bh
->
sizeof_elem
;
}
if
(
ib_bh
->
compare
(
last
,
ptr
)
<=
0
)
{
break
;
}
ib_bh_set
(
ib_bh
,
parent
,
ptr
);
parent
=
(
ptr
-
(
byte
*
)
ib_bh_first
(
ib_bh
))
/
ib_bh
->
sizeof_elem
;
if
((
parent
<<
1
)
>=
ib_bh_size
(
ib_bh
))
{
break
;
}
ptr
=
(
byte
*
)
ib_bh_get
(
ib_bh
,
parent
<<
1
);
}
--
ib_bh
->
n_elems
;
ib_bh_set
(
ib_bh
,
parent
,
last
);
}
storage/innobase/ut/ut0ut.c
View file @
19372f10
/*****************************************************************************
/*****************************************************************************
Copyright (c) 1994, 2010, Innobase Oy. All Rights Reserved.
Copyright (c) 2011, Oracle Corpn. All Rights Reserved.
Copyright (c) 2009, Sun Microsystems, Inc.
Portions of this file contain modifications contributed and copyrighted by
Sun Microsystems, Inc. Those modifications are gratefully acknowledged and
are described briefly in the InnoDB documentation. The contributions by
Sun Microsystems are incorporated with their permission, and subject to the
conditions contained in the file COPYING.Sun_Microsystems.
This program is free software; you can redistribute it and/or modify it under
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
the terms of the GNU General Public License as published by the Free Software
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment