Merge lp:~vkolesnikov/pbxt/pbxt-recovery-freeze-and-partitioned-tables into lp:pbxt

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-recovery-freeze-and-partitioned-tables
Merge into: lp:pbxt
Diff against target: None lines
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-recovery-freeze-and-partitioned-tables
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+7022@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 'ChangeLog'
2--- ChangeLog 2009-05-28 15:35:31 +0000
3+++ ChangeLog 2009-06-03 14:53:00 +0000
4@@ -3,6 +3,10 @@
5
6 ------- 1.0.08 RC - Not yet released
7
8+RN243: Fixed a bug that caused a recovery failure if partitioned pbxt tables where present. This happended because the recovery used a MySQL function to open tables and the PBXT handler was not yet registered
9+
10+RN242: Fixed a bug that caused a deadlock if pbxt initialization failed. This happened because pbxt ceanup was done from pbxt_init() with PLUGIN_lock being held by MySQL which lead to a deadlock in the freeer thread
11+
12 RN241: Fixed a heap corruption bug (writing to a freed memory location). It happened only when memory mapped files were used leading to heap inconsistency and program crash or termination by heap checker. Likely to happen right after or during DROP TABLE but possible in other cases too.
13
14 RN240: Load the record cache on read when no using memory mapped files.
15
16=== modified file 'src/ha_pbxt.cc'
17--- src/ha_pbxt.cc 2009-05-21 10:27:57 +0000
18+++ src/ha_pbxt.cc 2009-06-03 14:07:54 +0000
19@@ -105,6 +105,8 @@
20 static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share);
21 static void ha_close_open_tables(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine);
22
23+extern void xt_xres_start_database_recovery(XTThreadPtr self);
24+
25 #ifdef TRACE_STATEMENTS
26
27 #ifdef PRINT_STATEMENTS
28@@ -167,7 +169,7 @@
29 /* Variables for pbxt share methods */
30 static xt_mutex_type pbxt_database_mutex; // Prevent a database from being opened while it is being dropped
31 static XTHashTabPtr pbxt_share_tables; // Hash used to track open tables
32-static XTDatabaseHPtr pbxt_database = NULL; // The global open database
33+XTDatabaseHPtr pbxt_database = NULL; // The global open database
34 static char *pbxt_index_cache_size;
35 static char *pbxt_record_cache_size;
36 static char *pbxt_log_cache_size;
37@@ -1100,7 +1102,7 @@
38 #endif
39 self = xt_init_threading(pbxt_max_threads); /* Create the main self: */
40 if (!self)
41- goto error_4;
42+ goto error_3;
43
44 pbxt_inited = true;
45
46@@ -1164,9 +1166,7 @@
47 xt_throw(self);
48 }
49
50- xt_open_database(self, mysql_real_data_home, TRUE);
51- pbxt_database = self->st_database;
52- xt_heap_reference(self, pbxt_database);
53+ xt_xres_start_database_recovery(self);
54 }
55 catch_(b) {
56 if (!curr_thd && thd)
57@@ -1221,28 +1221,29 @@
58 * I have to stop the freeer here because it was
59 * started before opening the database.
60 */
61- pbxt_call_exit(self);
62- pbxt_inited = FALSE;
63- xt_exit_threading(self);
64- goto error_4;
65+
66+ /* {FREEER-HANG-ON-INIT-ERROR}
67+ * pbxt_init is called with LOCK_plugin and if it fails and tries to exit
68+ * the freeer here it hangs because the freeer calls THD::~THD which tries
69+ * to aquire the same lock and hangs. OTOH MySQL calls pbxt_end() after
70+ * an unsuccessful call to pbxt_init, so we defer cleaup, except
71+ * releasing 'self'
72+ */
73+ xt_free_thread(self);
74+ goto error_3;
75 }
76 xt_free_thread(self);
77 }
78 XT_RETURN(init_err);
79
80- error_4:
81- xt_exit_memory();
82-
83 error_3:
84 #ifdef XT_STREAMING
85 xt_exit_streaming();
86
87 error_2:
88 #endif
89- xt_exit_logging();
90
91 error_1:
92- xt_p_mutex_destroy(&pbxt_database_mutex);
93 XT_RETURN(1);
94 }
95
96@@ -1261,7 +1262,7 @@
97 XTExceptionRec e;
98
99 /* This flag also means "shutting down". */
100- pbxt_inited = FALSE;
101+ pbxt_inited = FALSE;
102 self = xt_create_thread("TempForEnd", FALSE, TRUE, &e);
103 if (self) {
104 self->t_main = TRUE;
105
106=== modified file 'src/restart_xt.cc'
107--- src/restart_xt.cc 2009-05-19 14:13:25 +0000
108+++ src/restart_xt.cc 2009-06-03 14:07:54 +0000
109@@ -3188,3 +3188,36 @@
110 done:
111 db->db_xlog.xlog_seq_exit(&seq);
112 }
113+
114+/* ----------------------------------------------------------------------
115+ * D A T A B A S E R E C O V E R Y T H R E A D
116+ */
117+
118+extern XTDatabaseHPtr pbxt_database;
119+
120+static void *xn_xres_run_recovery_thread(XTThreadPtr self)
121+{
122+ THD *mysql_thread;
123+
124+ mysql_thread = (THD *)myxt_create_thread();
125+
126+ while(!ha_resolve_by_legacy_type(mysql_thread, DB_TYPE_PBXT))
127+ xt_sleep_milli_second(1);
128+
129+ xt_open_database(self, mysql_real_data_home, TRUE);
130+ pbxt_database = self->st_database;
131+ xt_heap_reference(self, pbxt_database);
132+ myxt_destroy_thread(mysql_thread, TRUE);
133+
134+ return NULL;
135+}
136+
137+xtPublic void xt_xres_start_database_recovery(XTThreadPtr self)
138+{
139+ char name[PATH_MAX];
140+
141+ sprintf(name, "DB-RECOVERY-%s", xt_last_directory_of_path(mysql_real_data_home));
142+ xt_remove_dir_char(name);
143+ XTThreadPtr thread = xt_create_daemon(self, name);
144+ xt_run_thread(self, thread, xn_xres_run_recovery_thread);
145+}
146
147=== modified file 'src/restart_xt.h'
148--- src/restart_xt.h 2009-02-23 19:34:56 +0000
149+++ src/restart_xt.h 2009-06-03 13:13:32 +0000
150@@ -131,4 +131,6 @@
151 void xt_print_log_record(xtLogID log, off_t offset, XTXactLogBufferDPtr record);
152 void xt_dump_xlogs(struct XTDatabase *db, xtLogID start_log);
153
154+xtPublic void xt_xres_start_database_recovery(XTThreadPtr self, const char *path);
155+
156 #endif

Subscribers

People subscribed via source and target branches