Commit 4d29c792 authored by vasil's avatar vasil

branches/5.1:

Fix Bug#38996 Race condition in ANALYZE TABLE

by serializing ANALYZE TABLE inside InnoDB.

Approved by:	Heikki (rb://175)
parent 7c1d2b5f
......@@ -54,6 +54,7 @@ static ulong commit_threads = 0;
static pthread_mutex_t commit_threads_m;
static pthread_cond_t commit_cond;
static pthread_mutex_t commit_cond_m;
static pthread_mutex_t analyze_mutex;
static bool innodb_inited = 0;
/*
......@@ -1837,6 +1838,7 @@ innobase_init(
pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
pthread_mutex_init(&analyze_mutex, MY_MUTEX_INIT_FAST);
pthread_cond_init(&commit_cond, NULL);
innodb_inited= 1;
......@@ -1876,6 +1878,7 @@ innobase_end(handlerton *hton, ha_panic_function type)
pthread_mutex_destroy(&prepare_commit_mutex);
pthread_mutex_destroy(&commit_threads_m);
pthread_mutex_destroy(&commit_cond_m);
pthread_mutex_destroy(&analyze_mutex);
pthread_cond_destroy(&commit_cond);
}
......@@ -6335,9 +6338,15 @@ ha_innobase::analyze(
THD* thd, /* in: connection thread handle */
HA_CHECK_OPT* check_opt) /* in: currently ignored */
{
/* Serialize ANALYZE TABLE inside InnoDB, see
Bug#38996 Race condition in ANALYZE TABLE */
pthread_mutex_lock(&analyze_mutex);
/* Simply call ::info() with all the flags */
info(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE);
pthread_mutex_unlock(&analyze_mutex);
return(0);
}
......
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