summaryrefslogtreecommitdiff
path: root/storage/innobase/include
diff options
context:
space:
mode:
authorunknown <tsmith@quadxeon.mysql.com>2006-11-09 05:01:19 +0100
committerunknown <tsmith@quadxeon.mysql.com>2006-11-09 05:01:19 +0100
commit0ea6669e0498101dac8dac338100919f2768b96b (patch)
tree06753a2c6ffe49b9cc4d39f6179dc6510faf46a0 /storage/innobase/include
parentecfb2a75540bcf8133707b4879e6860730d73af2 (diff)
downloadmariadb-git-0ea6669e0498101dac8dac338100919f2768b96b.tar.gz
Applied innodb-5.1-ss1004
Fixes: - Bug #15815: Very poor performance with multiple queries running concurrently - Bug #22868: 'Thread thrashing' with > 50 concurrent conns under an upd-intensive workloadw - Bug #24089: Race condition in fil_flush_file_spaces() storage/innobase/btr/btr0btr.c: Applied innodb-5.1-ss1004 Revision r934: btr_lift_page_up(): Set new page levels in all ancestor pages, not just in the father page. btr0btr.h: Add a BTR_MAX_LEVELS define. storage/innobase/buf/buf0buf.c: Applied innodb-5.1-ss1004 Revision r999: Reduce buffer pool mutex contention under >= 4 big concurrent CPU-bound SELECT queries. (Bug #22868) Fix: replace the mutex by one mutex protecting the 'flush list' (and the free list) and several mutexes protecting portions of the buffer pool, where we keep several indivudual LRU lists of pages. This patch is from Sunny Bains and Heikki Tuuri. storage/innobase/buf/buf0flu.c: Applied innodb-5.1-ss1004 Revision r999: Reduce buffer pool mutex contention under >= 4 big concurrent CPU-bound SELECT queries. (Bug #22868) Fix: replace the mutex by one mutex protecting the 'flush list' (and the free list) and several mutexes protecting portions of the buffer pool, where we keep several indivudual LRU lists of pages. This patch is from Sunny Bains and Heikki Tuuri. storage/innobase/buf/buf0lru.c: Applied innodb-5.1-ss1004 Revision r999: Reduce buffer pool mutex contention under >= 4 big concurrent CPU-bound SELECT queries. (Bug #22868) Fix: replace the mutex by one mutex protecting the 'flush list' (and the free list) and several mutexes protecting portions of the buffer pool, where we keep several indivudual LRU lists of pages. This patch is from Sunny Bains and Heikki Tuuri. Revision r1004: UT_LIST_REMOVE(): Invalidate the node pointers #ifdef UNIV_DEBUG. buf_LRU_invalidate_tablespace(): Invoke UT_LIST_GET_PREV(LRU, block) before UT_LIST_REMOVE(LRU, buf_pool->LRU, block). storage/innobase/dict/dict0crea.c: Applied innodb-5.1-ss1004 Revision r973: Do not break the latching order in TRUNCATE TABLE. dict_truncate_index_tree(): Replace parameter rec_t* rec with btr_pcur_t* pcur. Reposition pcur before calling btr_create(). sync_thread_add_level(): Remove the relaxation of the assertion added in r968. storage/innobase/fil/fil0fil.c: Applied innodb-5.1-ss1004 Revision r1002: fil_flush_file_spaces(): Copy the system->unflushed_spaces list to an array while holding the mutex. This removes the crash-triggering race condition that was introduced when fixing Bug 15653. (Bug #24089) storage/innobase/include/btr0btr.h: Applied innodb-5.1-ss1004 Revision r934: btr_lift_page_up(): Set new page levels in all ancestor pages, not just in the father page. btr0btr.h: Add a BTR_MAX_LEVELS define. storage/innobase/include/buf0buf.h: Applied innodb-5.1-ss1004 Revision r999: Reduce buffer pool mutex contention under >= 4 big concurrent CPU-bound SELECT queries. (Bug #22868) Fix: replace the mutex by one mutex protecting the 'flush list' (and the free list) and several mutexes protecting portions of the buffer pool, where we keep several indivudual LRU lists of pages. This patch is from Sunny Bains and Heikki Tuuri. storage/innobase/include/buf0buf.ic: Applied innodb-5.1-ss1004 Revision r999: Reduce buffer pool mutex contention under >= 4 big concurrent CPU-bound SELECT queries. (Bug #22868) Fix: replace the mutex by one mutex protecting the 'flush list' (and the free list) and several mutexes protecting portions of the buffer pool, where we keep several indivudual LRU lists of pages. This patch is from Sunny Bains and Heikki Tuuri. storage/innobase/include/dict0crea.h: Applied innodb-5.1-ss1004 Revision r973: Do not break the latching order in TRUNCATE TABLE. dict_truncate_index_tree(): Replace parameter rec_t* rec with btr_pcur_t* pcur. Reposition pcur before calling btr_create(). sync_thread_add_level(): Remove the relaxation of the assertion added in r968. storage/innobase/include/ut0lst.h: Applied innodb-5.1-ss1004 Revision r1004: UT_LIST_REMOVE(): Invalidate the node pointers #ifdef UNIV_DEBUG. buf_LRU_invalidate_tablespace(): Invoke UT_LIST_GET_PREV(LRU, block) before UT_LIST_REMOVE(LRU, buf_pool->LRU, block). storage/innobase/row/row0mysql.c: Applied innodb-5.1-ss1004 Revision r973: Do not break the latching order in TRUNCATE TABLE. dict_truncate_index_tree(): Replace parameter rec_t* rec with btr_pcur_t* pcur. Reposition pcur before calling btr_create(). sync_thread_add_level(): Remove the relaxation of the assertion added in r968.
Diffstat (limited to 'storage/innobase/include')
-rw-r--r--storage/innobase/include/btr0btr.h12
-rw-r--r--storage/innobase/include/buf0buf.h40
-rw-r--r--storage/innobase/include/buf0buf.ic19
-rw-r--r--storage/innobase/include/dict0crea.h6
-rw-r--r--storage/innobase/include/ut0lst.h41
5 files changed, 80 insertions, 38 deletions
diff --git a/storage/innobase/include/btr0btr.h b/storage/innobase/include/btr0btr.h
index 664607a26aa..1573de7e818 100644
--- a/storage/innobase/include/btr0btr.h
+++ b/storage/innobase/include/btr0btr.h
@@ -23,7 +23,17 @@ special big record storage structure */
#define BTR_PAGE_MAX_REC_SIZE (UNIV_PAGE_SIZE / 2 - 200)
-/* Latching modes for the search function (in btr0cur.*) */
+/* Maximum depth of a B-tree in InnoDB. Note that this isn't a maximum as
+such; none of the tree operations avoid producing trees bigger than this. It
+is instead a "max depth that other code must work with", useful for e.g.
+fixed-size arrays that must store some information about each level in a
+tree. In other words: if a B-tree with bigger depth than this is
+encountered, it is not acceptable for it to lead to mysterious memory
+corruption, but it is acceptable for the program to die with a clear assert
+failure. */
+#define BTR_MAX_LEVELS 100
+
+/* Latching modes for btr_cur_search_to_nth_level(). */
#define BTR_SEARCH_LEAF RW_S_LATCH
#define BTR_MODIFY_LEAF RW_X_LATCH
#define BTR_NO_LATCHES RW_NO_LATCH
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 2fc6bf4bcb9..979c28f64ed 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -461,8 +461,8 @@ Gets the mutex number protecting the page record lock hash chain in the lock
table. */
UNIV_INLINE
mutex_t*
-buf_frame_get_lock_mutex(
-/*=====================*/
+buf_frame_get_mutex(
+/*================*/
/* out: mutex */
byte* ptr); /* in: pointer to within a buffer frame */
/***********************************************************************
@@ -713,7 +713,10 @@ struct buf_block_struct{
ulint magic_n; /* magic number to check */
ulint state; /* state of the control block:
- BUF_BLOCK_NOT_USED, ... */
+ BUF_BLOCK_NOT_USED, ...; changing
+ this is only allowed when a thread
+ has BOTH the buffer pool mutex AND
+ block->mutex locked */
byte* frame; /* pointer to buffer frame which
is of size UNIV_PAGE_SIZE, and
aligned to an address divisible by
@@ -731,8 +734,12 @@ struct buf_block_struct{
ulint offset; /* page number within the space */
ulint lock_hash_val; /* hashed value of the page address
in the record lock hash table */
- mutex_t* lock_mutex; /* mutex protecting the chain in the
- record lock hash table */
+ mutex_t mutex; /* mutex protecting this block:
+ state (also protected by the buffer
+ pool mutex), io_fix, buf_fix_count,
+ and accessed; we introduce this new
+ mutex in InnoDB-5.1 to relieve
+ contention on the buffer pool mutex */
rw_lock_t lock; /* read-write lock of the buffer
frame */
buf_block_t* hash; /* node used in chaining to the page
@@ -788,20 +795,27 @@ struct buf_block_struct{
in heuristic algorithms, because of
the possibility of a wrap-around! */
ulint freed_page_clock;/* the value of freed_page_clock
- buffer pool when this block was
- last time put to the head of the
- LRU list */
+ of the buffer pool when this block was
+ the last time put to the head of the
+ LRU list; a thread is allowed to
+ read this for heuristic purposes
+ without holding any mutex or latch */
ibool old; /* TRUE if the block is in the old
blocks in the LRU list */
ibool accessed; /* TRUE if the page has been accessed
while in the buffer pool: read-ahead
may read in pages which have not been
- accessed yet */
+ accessed yet; this is protected by
+ block->mutex; a thread is allowed to
+ read this for heuristic purposes
+ without holding any mutex or latch */
ulint buf_fix_count; /* count of how manyfold this block
- is currently bufferfixed */
+ is currently bufferfixed; this is
+ protected by block->mutex */
ulint io_fix; /* if a read is pending to the frame,
io_fix is BUF_IO_READ, in the case
- of a write BUF_IO_WRITE, otherwise 0 */
+ of a write BUF_IO_WRITE, otherwise 0;
+ this is protected by block->mutex */
/* 4. Optimistic search field */
dulint modify_clock; /* this clock is incremented every
@@ -959,7 +973,9 @@ struct buf_pool_struct{
number of buffer blocks removed from
the end of the LRU list; NOTE that
this counter may wrap around at 4
- billion! */
+ billion! A thread is allowed to
+ read this for heuristic purposes
+ without holding any mutex or latch */
ulint LRU_flush_ended;/* when an LRU flush ends for a page,
this is incremented by one; this is
set to zero when a buffer block is
diff --git a/storage/innobase/include/buf0buf.ic b/storage/innobase/include/buf0buf.ic
index 015de862705..43895295734 100644
--- a/storage/innobase/include/buf0buf.ic
+++ b/storage/innobase/include/buf0buf.ic
@@ -337,8 +337,8 @@ Gets the mutex number protecting the page record lock hash chain in the lock
table. */
UNIV_INLINE
mutex_t*
-buf_frame_get_lock_mutex(
-/*=====================*/
+buf_frame_get_mutex(
+/*================*/
/* out: mutex */
byte* ptr) /* in: pointer to within a buffer frame */
{
@@ -346,7 +346,7 @@ buf_frame_get_lock_mutex(
block = buf_block_align(ptr);
- return(block->lock_mutex);
+ return(&block->mutex);
}
/*************************************************************************
@@ -519,6 +519,7 @@ buf_block_buf_fix_inc_debug(
ret = rw_lock_s_lock_func_nowait(&(block->debug_latch), file, line);
ut_ad(ret == TRUE);
+ ut_ad(mutex_own(&block->mutex));
#endif
block->buf_fix_count++;
}
@@ -531,6 +532,9 @@ buf_block_buf_fix_inc(
/*==================*/
buf_block_t* block) /* in: block to bufferfix */
{
+#ifdef UNIV_SYNC_DEBUG
+ ut_ad(mutex_own(&block->mutex));
+#endif
block->buf_fix_count++;
}
#endif /* UNIV_SYNC_DEBUG */
@@ -625,23 +629,24 @@ buf_page_release(
ut_ad(block);
- mutex_enter_fast(&(buf_pool->mutex));
-
ut_a(block->state == BUF_BLOCK_FILE_PAGE);
ut_a(block->buf_fix_count > 0);
if (rw_latch == RW_X_LATCH && mtr->modifications) {
-
+ mutex_enter(&buf_pool->mutex);
buf_flush_note_modification(block, mtr);
+ mutex_exit(&buf_pool->mutex);
}
+ mutex_enter(&block->mutex);
+
#ifdef UNIV_SYNC_DEBUG
rw_lock_s_unlock(&(block->debug_latch));
#endif
buf_fix_count = block->buf_fix_count;
block->buf_fix_count = buf_fix_count - 1;
- mutex_exit(&(buf_pool->mutex));
+ mutex_exit(&block->mutex);
if (rw_latch == RW_S_LATCH) {
rw_lock_s_unlock(&(block->lock));
diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h
index bd0890dbfa7..f0f30481abe 100644
--- a/storage/innobase/include/dict0crea.h
+++ b/storage/innobase/include/dict0crea.h
@@ -62,8 +62,10 @@ dict_truncate_index_tree(
/* out: new root page number, or
FIL_NULL on failure */
dict_table_t* table, /* in: the table the index belongs to */
- rec_t* rec, /* in: record in the clustered index of
- SYS_INDEXES table */
+ btr_pcur_t* pcur, /* in/out: persistent cursor pointing to
+ record in the clustered index of
+ SYS_INDEXES table. The cursor may be
+ repositioned in this call. */
mtr_t* mtr); /* in: mtr having the latch
on the record page. The mtr may be
committed and restarted in this call. */
diff --git a/storage/innobase/include/ut0lst.h b/storage/innobase/include/ut0lst.h
index 819f2e770ba..d19885d6edc 100644
--- a/storage/innobase/include/ut0lst.h
+++ b/storage/innobase/include/ut0lst.h
@@ -123,27 +123,36 @@ name, NODE1 and NODE2 are pointers to nodes. */
}\
}\
+/* Invalidate the pointers in a list node. */
+#ifdef UNIV_DEBUG
+# define UT_LIST_REMOVE_CLEAR(NAME, N) \
+((N)->NAME.prev = (N)->NAME.next = (void*) -1)
+#else
+# define UT_LIST_REMOVE_CLEAR(NAME, N) while (0)
+#endif
+
/***********************************************************************
Removes a node from a two-way linked list. BASE has to be the base node
(not a pointer to it). N has to be the pointer to the node to be removed
from the list. NAME is the list name. */
-#define UT_LIST_REMOVE(NAME, BASE, N)\
-{\
- ut_ad(N);\
- ut_a((BASE).count > 0);\
- ((BASE).count)--;\
- if (((N)->NAME).next != NULL) {\
- ((((N)->NAME).next)->NAME).prev = ((N)->NAME).prev;\
- } else {\
- (BASE).end = ((N)->NAME).prev;\
- }\
- if (((N)->NAME).prev != NULL) {\
- ((((N)->NAME).prev)->NAME).next = ((N)->NAME).next;\
- } else {\
- (BASE).start = ((N)->NAME).next;\
- }\
-}\
+#define UT_LIST_REMOVE(NAME, BASE, N) \
+do { \
+ ut_ad(N); \
+ ut_a((BASE).count > 0); \
+ ((BASE).count)--; \
+ if (((N)->NAME).next != NULL) { \
+ ((((N)->NAME).next)->NAME).prev = ((N)->NAME).prev; \
+ } else { \
+ (BASE).end = ((N)->NAME).prev; \
+ } \
+ if (((N)->NAME).prev != NULL) { \
+ ((((N)->NAME).prev)->NAME).next = ((N)->NAME).next; \
+ } else { \
+ (BASE).start = ((N)->NAME).next; \
+ } \
+ UT_LIST_REMOVE_CLEAR(NAME, N); \
+} while (0)
/************************************************************************
Gets the next node in a two-way list. NAME is the name of the list