Commit 54f2ca00 authored by Paul McCullagh's avatar Paul McCullagh

Merged with trunk

parent d825d44f
......@@ -1145,6 +1145,7 @@ static int pbxt_init(void *p)
pbxt_hton->panic = pbxt_panic; /* Panic call */
pbxt_hton->show_status = pbxt_show_status;
pbxt_hton->flags = HTON_NO_FLAGS; /* HTON_CAN_RECREATE - Without this flags TRUNCATE uses delete_all_rows() */
pbxt_hton->slot = (uint)-1; /* assign invald value, so we know when it's inited later */
#if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP)
pbxt_hton->get_backup_engine = pbxt_backup_engine;
#endif
......@@ -1227,7 +1228,9 @@ static int pbxt_init(void *p)
* Only real problem, 2 threads try to load the same
* plugin at the same time.
*/
#if MYSQL_VERSION_ID < 60014
myxt_mutex_unlock(&LOCK_plugin);
#endif
#endif
/* Can't do this here yet, because I need a THD! */
......@@ -1262,7 +1265,9 @@ static int pbxt_init(void *p)
if (thd)
myxt_destroy_thread(thd, FALSE);
#ifndef DRIZZLED
#if MYSQL_VERSION_ID < 60014
myxt_mutex_lock(&LOCK_plugin);
#endif
#endif
}
#endif
......@@ -5817,17 +5822,19 @@ static MYSQL_SYSVAR_INT(max_threads, pbxt_max_threads,
NULL, NULL, 0, 0, 20000, 1);
#endif
#ifndef DEBUG
static MYSQL_SYSVAR_BOOL(support_xa, pbxt_support_xa,
PLUGIN_VAR_OPCMDARG,
"Enable PBXT support for the XA two-phase commit, default is enabled",
NULL, NULL, TRUE);
#else
static MYSQL_SYSVAR_BOOL(support_xa, pbxt_support_xa,
PLUGIN_VAR_OPCMDARG,
#ifdef DEBUG
"Enable PBXT support for the XA two-phase commit, default is disabled (due to assertion failure in MySQL)",
/* The problem is, in MySQL an assertion fails in debug mode:
* Assertion failed: (total_ha_2pc == (ulong) opt_bin_log+1), function ha_recover, file handler.cc, line 1557.
*/
NULL, NULL, FALSE);
#else
"Enable PBXT support for the XA two-phase commit, default is enabled",
NULL, NULL, TRUE);
#endif
static struct st_mysql_sys_var* pbxt_system_variables[] = {
......
......@@ -24,11 +24,16 @@
#ifndef __xt_locklist_h__
#define __xt_locklist_h__
/*
* XT_THREAD_LOCK_INFO and DEBUG_LOCKING code must be updated to avoid calls to xt_get_self() as it can be called before hton->slot is
* assigned by MySQL which is used by xt_get_self()
*/
#ifdef DEBUG
#define XT_THREAD_LOCK_INFO
//#define XT_THREAD_LOCK_INFO
#ifndef XT_WIN
/* We need DEBUG_LOCKING in order to enable pthread function wrappers */
#define DEBUG_LOCKING
//#define DEBUG_LOCKING
#endif
#endif
......
......@@ -3364,3 +3364,29 @@ XTDDColumn *XTDDColumnFactory::createFromMySQLField(XTThread *self, TABLE *my_ta
return col;
}
/*
* -----------------------------------------------------------------------
* utilities
*/
/*
* MySQL (not sure about Drizzle) first calls hton->init and then assigns the plugin a thread slot
* which is used by xt_get_self(). This is a problem as pbxt_init() starts a number of daemon threads
* which could try to use the slot before it is assigned. This code waits till slot is inited.
* We cannot directly check hton->slot as in some versions of MySQL it can be 0 before init which is a
* valid value.
*/
extern ulong total_ha;
xtPublic void myxt_wait_pbxt_plugin_slot_assigned(XTThread *self)
{
#ifdef DRIZZLED
static LEX_STRING plugin_name = { C_STRING_WITH_LEN("PBXT") };
while (!self->t_quit && !Registry::singleton().find(&plugin_name))
xt_sleep_milli_second(1);
#else
while(!self->t_quit && (pbxt_hton->slot >= total_ha))
xt_sleep_milli_second(1);
#endif
}
......@@ -95,4 +95,6 @@ class XTDDColumnFactory
static XTDDColumn *createFromMySQLField(XTThread *self, STRUCT_TABLE *, Field *);
};
void myxt_wait_pbxt_plugin_slot_assigned(XTThread *self);
#endif
......@@ -3251,15 +3251,7 @@ static void *xn_xres_run_recovery_thread(XTThreadPtr self)
if (!(mysql_thread = (THD *) myxt_create_thread()))
xt_throw(self);
#ifdef DRIZZLED
static LEX_STRING plugin_name = { C_STRING_WITH_LEN("PBXT") };
while (!xres_recovery_thread->t_quit && !Registry::singleton().find(&plugin_name))
xt_sleep_milli_second(1);
#else
while (!xres_recovery_thread->t_quit && !ha_resolve_by_legacy_type(mysql_thread, DB_TYPE_PBXT))
xt_sleep_milli_second(1);
#endif
myxt_wait_pbxt_plugin_slot_assigned(self);
if (!xres_recovery_thread->t_quit) {
try_(a) {
......
......@@ -1150,6 +1150,8 @@ static void *tabc_fr_run_thread(XTThreadPtr self)
int count;
void *mysql_thread;
myxt_wait_pbxt_plugin_slot_assigned(self);
mysql_thread = myxt_create_thread();
while (!self->t_quit) {
......
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