Merge lp:~vkolesnikov/pbxt/pbxt-hton-slot into lp:pbxt

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-hton-slot
Merge into: lp:pbxt
Diff against target: 172 lines (+52/-18)
6 files modified
src/ha_pbxt.cc (+14/-7)
src/locklist_xt.h (+7/-2)
src/myxt_xt.cc (+26/-0)
src/myxt_xt.h (+2/-0)
src/restart_xt.cc (+1/-9)
src/tabcache_xt.cc (+2/-0)
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-hton-slot
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+15286@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ha_pbxt.cc'
2--- src/ha_pbxt.cc 2009-11-25 13:35:18 +0000
3+++ src/ha_pbxt.cc 2009-11-27 14:16:11 +0000
4@@ -1103,7 +1103,6 @@
5 printf("PBXT: This won't work, I require that sizeof(xtWordPS) == sizeof(void *)!\n");
6 XT_RETURN(1);
7 }
8-
9 /* GOTCHA: This will "detect" if are loading the plug-in
10 * with different --with-debug option to MySQL.
11 *
12@@ -1145,6 +1144,7 @@
13 pbxt_hton->panic = pbxt_panic; /* Panic call */
14 pbxt_hton->show_status = pbxt_show_status;
15 pbxt_hton->flags = HTON_NO_FLAGS; /* HTON_CAN_RECREATE - Without this flags TRUNCATE uses delete_all_rows() */
16+ pbxt_hton->slot = (uint)-1; /* assign invald value, so we know when it's inited later */
17 #if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP)
18 pbxt_hton->get_backup_engine = pbxt_backup_engine;
19 #endif
20@@ -1227,8 +1227,10 @@
21 * Only real problem, 2 threads try to load the same
22 * plugin at the same time.
23 */
24+#if MYSQL_VERSION_ID < 60014
25 myxt_mutex_unlock(&LOCK_plugin);
26 #endif
27+#endif
28
29 /* Can't do this here yet, because I need a THD! */
30 try_(b) {
31@@ -1262,8 +1264,10 @@
32 if (thd)
33 myxt_destroy_thread(thd, FALSE);
34 #ifndef DRIZZLED
35+#if MYSQL_VERSION_ID < 60014
36 myxt_mutex_lock(&LOCK_plugin);
37 #endif
38+#endif
39 }
40 #endif
41 }
42@@ -5817,19 +5821,22 @@
43 NULL, NULL, 0, 0, 20000, 1);
44 #endif
45
46-static MYSQL_SYSVAR_BOOL(support_xa, pbxt_support_xa,
47- PLUGIN_VAR_OPCMDARG,
48-#ifdef DEBUG
49+#ifndef DEBUG
50+static MYSQL_SYSVAR_BOOL(support_xa, pbxt_support_xa,
51+ PLUGIN_VAR_OPCMDARG,
52+ "Enable PBXT support for the XA two-phase commit, default is enabled",
53+ NULL, NULL, TRUE);
54+#else
55+static MYSQL_SYSVAR_BOOL(support_xa, pbxt_support_xa,
56+ PLUGIN_VAR_OPCMDARG,
57 "Enable PBXT support for the XA two-phase commit, default is disabled (due to assertion failure in MySQL)",
58 /* The problem is, in MySQL an assertion fails in debug mode:
59 * Assertion failed: (total_ha_2pc == (ulong) opt_bin_log+1), function ha_recover, file handler.cc, line 1557.
60 */
61 NULL, NULL, FALSE);
62-#else
63- "Enable PBXT support for the XA two-phase commit, default is enabled",
64- NULL, NULL, TRUE);
65 #endif
66
67+
68 static struct st_mysql_sys_var* pbxt_system_variables[] = {
69 MYSQL_SYSVAR(index_cache_size),
70 MYSQL_SYSVAR(record_cache_size),
71
72=== modified file 'src/locklist_xt.h'
73--- src/locklist_xt.h 2009-05-28 15:17:16 +0000
74+++ src/locklist_xt.h 2009-11-27 14:16:11 +0000
75@@ -24,11 +24,16 @@
76 #ifndef __xt_locklist_h__
77 #define __xt_locklist_h__
78
79+/*
80+ * 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
81+ * assigned by MySQL which is used by xt_get_self()
82+ */
83+
84 #ifdef DEBUG
85-#define XT_THREAD_LOCK_INFO
86+//#define XT_THREAD_LOCK_INFO
87 #ifndef XT_WIN
88 /* We need DEBUG_LOCKING in order to enable pthread function wrappers */
89-#define DEBUG_LOCKING
90+//#define DEBUG_LOCKING
91 #endif
92 #endif
93
94
95=== modified file 'src/myxt_xt.cc'
96--- src/myxt_xt.cc 2009-11-11 10:20:47 +0000
97+++ src/myxt_xt.cc 2009-11-27 14:16:11 +0000
98@@ -3364,3 +3364,29 @@
99 return col;
100 }
101
102+/*
103+ * -----------------------------------------------------------------------
104+ * utilities
105+ */
106+
107+/*
108+ * MySQL (not sure about Drizzle) first calls hton->init and then assigns the plugin a thread slot
109+ * which is used by xt_get_self(). This is a problem as pbxt_init() starts a number of daemon threads
110+ * which could try to use the slot before it is assigned. This code waits till slot is inited.
111+ * We cannot directly check hton->slot as in some versions of MySQL it can be 0 before init which is a
112+ * valid value.
113+ */
114+extern ulong total_ha;
115+
116+xtPublic void myxt_wait_pbxt_plugin_slot_assigned(XTThread *self)
117+{
118+#ifdef DRIZZLED
119+ static LEX_STRING plugin_name = { C_STRING_WITH_LEN("PBXT") };
120+
121+ while (!self->t_quit && !Registry::singleton().find(&plugin_name))
122+ xt_sleep_milli_second(1);
123+#else
124+ while(!self->t_quit && (pbxt_hton->slot >= total_ha))
125+ xt_sleep_milli_second(1);
126+#endif
127+}
128
129=== modified file 'src/myxt_xt.h'
130--- src/myxt_xt.h 2009-09-08 10:54:00 +0000
131+++ src/myxt_xt.h 2009-11-27 14:16:12 +0000
132@@ -95,4 +95,6 @@
133 static XTDDColumn *createFromMySQLField(XTThread *self, STRUCT_TABLE *, Field *);
134 };
135
136+void myxt_wait_pbxt_plugin_slot_assigned(XTThread *self);
137+
138 #endif
139
140=== modified file 'src/restart_xt.cc'
141--- src/restart_xt.cc 2009-11-18 10:25:26 +0000
142+++ src/restart_xt.cc 2009-11-27 14:16:12 +0000
143@@ -3251,15 +3251,7 @@
144 if (!(mysql_thread = (THD *) myxt_create_thread()))
145 xt_throw(self);
146
147-#ifdef DRIZZLED
148- static LEX_STRING plugin_name = { C_STRING_WITH_LEN("PBXT") };
149-
150- while (!xres_recovery_thread->t_quit && !Registry::singleton().find(&plugin_name))
151- xt_sleep_milli_second(1);
152-#else
153- while (!xres_recovery_thread->t_quit && !ha_resolve_by_legacy_type(mysql_thread, DB_TYPE_PBXT))
154- xt_sleep_milli_second(1);
155-#endif
156+ myxt_wait_pbxt_plugin_slot_assigned(self);
157
158 if (!xres_recovery_thread->t_quit) {
159 try_(a) {
160
161=== modified file 'src/tabcache_xt.cc'
162--- src/tabcache_xt.cc 2009-09-08 10:52:24 +0000
163+++ src/tabcache_xt.cc 2009-11-27 14:16:12 +0000
164@@ -1150,6 +1150,8 @@
165 int count;
166 void *mysql_thread;
167
168+ myxt_wait_pbxt_plugin_slot_assigned(self);
169+
170 mysql_thread = myxt_create_thread();
171
172 while (!self->t_quit) {

Subscribers

People subscribed via source and target branches