Below is the list of changes that have just been committed into a local
5.2 repository of psergey. When psergey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-12-13 23:54:22+03:00, sergefp@stripped +3 -0
Experimental code, will not be pushed:
Make DS-MRR implementation serialize disk sweep passes using a mutex.
sql/handler.cc@stripped, 2007-12-13 23:54:17+03:00, sergefp@stripped +35 -1
Experimental code, will not be pushed:
Make DS-MRR implementation serialize disk sweep passes using a mutex.
sql/handler.h@stripped, 2007-12-13 23:54:17+03:00, sergefp@stripped +11 -2
Experimental code, will not be pushed:
Make DS-MRR implementation serialize disk sweep passes using a mutex.
sql/mysqld.cc@stripped, 2007-12-13 23:54:17+03:00, sergefp@stripped +2 -0
Experimental code, will not be pushed:
Make DS-MRR implementation serialize disk sweep passes using a mutex.
diff -Nrup a/sql/handler.cc b/sql/handler.cc
--- a/sql/handler.cc 2007-10-22 16:30:00 +04:00
+++ b/sql/handler.cc 2007-12-13 23:54:17 +03:00
@@ -3414,6 +3414,17 @@ start:
/****************************************************************************
* DS-MRR implementation
***************************************************************************/
+pthread_mutex_t dsmrr_mutex;
+pthread_mutexattr_t dsmrr_mutex_attr;
+
+void dsmrr_static_init()
+{
+ if (pthread_mutexattr_init(&dsmrr_mutex_attr))
+ fprintf(stderr, "dsmrr_mutex pthread_mutexattr_init failed\n");
+ pthread_mutexattr_settype(&dsmrr_mutex_attr, PTHREAD_MUTEX_RECURSIVE);
+ if (pthread_mutex_init(&dsmrr_mutex, &dsmrr_mutex_attr))
+ fprintf(stderr, "dsmrr_mutex pthread_mutex_init failed\n");
+}
/*
DS-MRR: Initialize and start MRR scan
@@ -3516,7 +3527,15 @@ int DsMrr_impl::dsmrr_init(handler *h, K
&row_access_bitmap);
if (h2->rnd_init(FALSE))
goto error;
-
+
+ /*
+ The 'normal' state of initialized DS-MRR scan is disk-sweep, which is
+ interrupted by periods when we walk the index.
+
+ So we lock the mutex now and will unlock it when doing disk sweeps.
+ */
+ pthread_mutex_lock(&dsmrr_mutex);
+ need_unlock= TRUE;
DBUG_RETURN(0);
error:
h2->ha_external_lock(thd, F_UNLCK);
@@ -3530,6 +3549,11 @@ error:
void DsMrr_impl::dsmrr_close()
{
DBUG_ENTER("DsMrr_impl::dsmrr_close");
+ if (need_unlock)
+ {
+ pthread_mutex_unlock(&dsmrr_mutex);
+ need_unlock= FALSE;
+ }
if (h2)
{
h2->ha_external_lock(current_thd, F_UNLCK);
@@ -3623,6 +3647,8 @@ int DsMrr_impl::dsmrr_next(handler *h, c
do
{
+ pthread_mutex_unlock(&dsmrr_mutex);
+ need_unlock= FALSE;
if (rowids_buf_cur == rowids_buf_last)
{
h->table->column_bitmaps_set_no_signal(save_read_set, save_write_set);
@@ -3636,7 +3662,10 @@ int DsMrr_impl::dsmrr_next(handler *h, c
h->table->column_bitmaps_set_no_signal(&row_access_bitmap,
&row_access_bitmap);
if (res)
+ {
+ // Keep unlocked.
goto end;
+ }
}
/* Return EOF if there are no rowids in the buffer after re-fill attempt */
@@ -3645,6 +3674,11 @@ int DsMrr_impl::dsmrr_next(handler *h, c
res= HA_ERR_END_OF_FILE;
goto end;
}
+
+ /* Switching to Sweep read read. Lock the mutex back */
+ need_unlock= TRUE;
+ pthread_mutex_lock(&dsmrr_mutex);
+
cur_rowid= rowids_buf_cur;
rowids_buf_cur += h->ref_length + sizeof(void*) * test(is_mrr_assoc);
diff -Nrup a/sql/handler.h b/sql/handler.h
--- a/sql/handler.h 2007-10-20 20:04:55 +04:00
+++ b/sql/handler.h 2007-12-13 23:54:17 +03:00
@@ -2044,6 +2044,15 @@ private:
/*
+ A mutex used to disallow two disk sweeps to run at the same time.
+
+*/
+extern pthread_mutex_t dsmrr_mutex;
+extern pthread_mutexattr_t dsmrr_mutex_attr;
+
+void dsmrr_static_init();
+
+/*
A Disk-Sweep MRR interface implementation
This implementation makes range (and, in the future, 'ref') scans to read
@@ -2074,7 +2083,7 @@ public:
/* TRUE <=> need range association, buffer holds {rowid, range_id} pairs */
bool is_mrr_assoc;
-
+
/*
TRUE <=> doing a first-match semi-join, check if we need any more records in
the scanned range
@@ -2091,7 +2100,7 @@ public:
bool use_default_impl; /* TRUE <=> shortcut the calls to default MRR impl */
range_check_toggle_func_t range_check_toggle_func;
-
+ bool need_unlock;
int dsmrr_init(handler *h, KEY *key, RANGE_SEQ_IF *seq_funcs,
void *seq_init_param, uint n_ranges, uint mode,
HANDLER_BUFFER *buf);
diff -Nrup a/sql/mysqld.cc b/sql/mysqld.cc
--- a/sql/mysqld.cc 2007-10-22 16:30:00 +04:00
+++ b/sql/mysqld.cc 2007-12-13 23:54:17 +03:00
@@ -3713,6 +3713,7 @@ void decrement_handler_count()
#define decrement_handler_count()
#endif /* defined(__NT__) || defined(HAVE_SMEM) */
+void dsmrr_static_init();
#ifndef EMBEDDED_LIBRARY
#ifdef __WIN__
@@ -3736,6 +3737,7 @@ int main(int argc, char **argv)
MY_INIT, as it initializes mutexes. Log tables are inited later.
*/
logger.init_base();
+ dsmrr_static_init();
#ifdef _CUSTOMSTARTUPCONFIG_
if (_cust_check_startup())
| Thread |
|---|
| • bk commit into 5.2 tree (sergefp:1.2594) | Sergey Petrunia | 13 Dec |