Merge lp:~laurynas-biveinis/percona-server/bug1012715-5.5 into lp:percona-server/5.5
- bug1012715-5.5
- Merge into 5.5
Proposed by
Laurynas Biveinis
Status: | Merged |
---|---|
Approved by: | Alexey Kopytov |
Approved revision: | no longer in the source branch. |
Merged at revision: | 329 |
Proposed branch: | lp:~laurynas-biveinis/percona-server/bug1012715-5.5 |
Merge into: | lp:percona-server/5.5 |
Diff against target: |
869 lines (+523/-165) 7 files modified
Percona-Server/mysql-test/suite/rpl/r/rpl_percona_crash_resistant_rpl.result (+54/-0) Percona-Server/mysql-test/suite/rpl/t/rpl_percona_crash_resistant_rpl-slave.opt (+1/-0) Percona-Server/mysql-test/suite/rpl/t/rpl_percona_crash_resistant_rpl.test (+117/-0) Percona-Server/storage/innobase/handler/ha_innodb.cc (+221/-108) Percona-Server/storage/innobase/include/trx0sys.h (+15/-1) Percona-Server/storage/innobase/trx/trx0sys.c (+96/-54) Percona-Server/storage/innobase/trx/trx0trx.c (+19/-2) |
To merge this branch: | bzr merge lp:~laurynas-biveinis/percona-server/bug1012715-5.5 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alexey Kopytov (community) | Approve | ||
Review via email: mp+120043@code.launchpad.net |
This proposal supersedes a proposal from 2012-06-29.
Commit message
Description of the change
Merge bug 1012715 fix from 5.1 manually.
http://
Issue 22478
To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) wrote : Posted in a previous version of this proposal | # |
review:
Needs Fixing
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
Please ping me if you are about to review this.
Revision history for this message
Alexey Kopytov (akopytov) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'Percona-Server/mysql-test/suite/rpl/r/rpl_percona_crash_resistant_rpl.result' | |||
2 | --- Percona-Server/mysql-test/suite/rpl/r/rpl_percona_crash_resistant_rpl.result 1970-01-01 00:00:00 +0000 | |||
3 | +++ Percona-Server/mysql-test/suite/rpl/r/rpl_percona_crash_resistant_rpl.result 2012-08-17 02:53:37 +0000 | |||
4 | @@ -0,0 +1,54 @@ | |||
5 | 1 | include/master-slave.inc | ||
6 | 2 | [connection master] | ||
7 | 3 | DROP TABLE IF EXISTS t1; | ||
8 | 4 | CREATE TABLE t1 (id INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB; | ||
9 | 5 | INSERT INTO t1 VALUES (); | ||
10 | 6 | SELECT COUNT(*) FROM t1; | ||
11 | 7 | COUNT(*) | ||
12 | 8 | 1 | ||
13 | 9 | include/rpl_restart_server.inc [server_number=2] | ||
14 | 10 | include/start_slave.inc | ||
15 | 11 | SELECT COUNT(*) FROM t1; | ||
16 | 12 | COUNT(*) | ||
17 | 13 | 1 | ||
18 | 14 | STOP SLAVE; | ||
19 | 15 | include/wait_for_slave_to_stop.inc | ||
20 | 16 | INSERT INTO t1 VALUES(); | ||
21 | 17 | SELECT COUNT(*) FROM t1; | ||
22 | 18 | COUNT(*) | ||
23 | 19 | 2 | ||
24 | 20 | SET GLOBAL debug="+d,crash_commit_before"; | ||
25 | 21 | START SLAVE; | ||
26 | 22 | include/rpl_start_server.inc [server_number=2] | ||
27 | 23 | include/start_slave.inc | ||
28 | 24 | SELECT COUNT(*) FROM t1; | ||
29 | 25 | COUNT(*) | ||
30 | 26 | 2 | ||
31 | 27 | STOP SLAVE; | ||
32 | 28 | include/wait_for_slave_to_stop.inc | ||
33 | 29 | INSERT INTO t1 VALUES(); | ||
34 | 30 | SELECT COUNT(*) FROM t1; | ||
35 | 31 | COUNT(*) | ||
36 | 32 | 3 | ||
37 | 33 | SET GLOBAL debug="+d,crash_innodb_after_prepare"; | ||
38 | 34 | START SLAVE; | ||
39 | 35 | include/rpl_start_server.inc [server_number=2] | ||
40 | 36 | include/start_slave.inc | ||
41 | 37 | SELECT COUNT(*) FROM t1; | ||
42 | 38 | COUNT(*) | ||
43 | 39 | 3 | ||
44 | 40 | STOP SLAVE; | ||
45 | 41 | include/wait_for_slave_to_stop.inc | ||
46 | 42 | INSERT INTO t1 VALUES(); | ||
47 | 43 | SELECT COUNT(*) FROM t1; | ||
48 | 44 | COUNT(*) | ||
49 | 45 | 4 | ||
50 | 46 | SET GLOBAL debug="+d,crash_innodb_before_commit"; | ||
51 | 47 | START SLAVE; | ||
52 | 48 | include/rpl_start_server.inc [server_number=2] | ||
53 | 49 | include/start_slave.inc | ||
54 | 50 | SELECT COUNT(*) FROM t1; | ||
55 | 51 | COUNT(*) | ||
56 | 52 | 4 | ||
57 | 53 | DROP TABLE t1; | ||
58 | 54 | include/rpl_end.inc | ||
59 | 0 | 55 | ||
60 | === added file 'Percona-Server/mysql-test/suite/rpl/t/rpl_percona_crash_resistant_rpl-slave.opt' | |||
61 | --- Percona-Server/mysql-test/suite/rpl/t/rpl_percona_crash_resistant_rpl-slave.opt 1970-01-01 00:00:00 +0000 | |||
62 | +++ Percona-Server/mysql-test/suite/rpl/t/rpl_percona_crash_resistant_rpl-slave.opt 2012-08-17 02:53:37 +0000 | |||
63 | @@ -0,0 +1,1 @@ | |||
64 | 1 | --innodb-recovery-update-relay-log=TRUE --skip-core-file --skip-stack-trace | ||
65 | 0 | 2 | ||
66 | === added file 'Percona-Server/mysql-test/suite/rpl/t/rpl_percona_crash_resistant_rpl.test' | |||
67 | --- Percona-Server/mysql-test/suite/rpl/t/rpl_percona_crash_resistant_rpl.test 1970-01-01 00:00:00 +0000 | |||
68 | +++ Percona-Server/mysql-test/suite/rpl/t/rpl_percona_crash_resistant_rpl.test 2012-08-17 02:53:37 +0000 | |||
69 | @@ -0,0 +1,117 @@ | |||
70 | 1 | # Tests for Percona crash-resistant replication feature | ||
71 | 2 | --source include/have_innodb.inc | ||
72 | 3 | --source include/master-slave.inc | ||
73 | 4 | --source include/not_valgrind.inc | ||
74 | 5 | --source include/not_crashrep.inc | ||
75 | 6 | --source include/have_debug.inc | ||
76 | 7 | |||
77 | 8 | # | ||
78 | 9 | # Setup | ||
79 | 10 | # | ||
80 | 11 | |||
81 | 12 | --disable_query_log | ||
82 | 13 | call mtr.add_suppression("InnoDB: Warning: innodb_overwrite_relay_log_info is enabled."); | ||
83 | 14 | --enable_query_log | ||
84 | 15 | |||
85 | 16 | connection master; | ||
86 | 17 | |||
87 | 18 | --disable_warnings | ||
88 | 19 | DROP TABLE IF EXISTS t1; | ||
89 | 20 | --enable_warnings | ||
90 | 21 | |||
91 | 22 | CREATE TABLE t1 (id INT(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)) ENGINE=InnoDB; | ||
92 | 23 | |||
93 | 24 | # | ||
94 | 25 | # Test the non-crashing case | ||
95 | 26 | # | ||
96 | 27 | |||
97 | 28 | INSERT INTO t1 VALUES (); | ||
98 | 29 | SELECT COUNT(*) FROM t1; | ||
99 | 30 | |||
100 | 31 | sync_slave_with_master; | ||
101 | 32 | --let $rpl_server_number= 2 | ||
102 | 33 | --source include/rpl_restart_server.inc | ||
103 | 34 | --source include/start_slave.inc | ||
104 | 35 | SELECT COUNT(*) FROM t1; | ||
105 | 36 | |||
106 | 37 | # | ||
107 | 38 | # Test the crashing case where relay-log.info needs not to be overwritten | ||
108 | 39 | # | ||
109 | 40 | |||
110 | 41 | STOP SLAVE; | ||
111 | 42 | --source include/wait_for_slave_to_stop.inc | ||
112 | 43 | |||
113 | 44 | connection master; | ||
114 | 45 | INSERT INTO t1 VALUES(); | ||
115 | 46 | SELECT COUNT(*) FROM t1; | ||
116 | 47 | |||
117 | 48 | connection slave; | ||
118 | 49 | SET GLOBAL debug="+d,crash_commit_before"; | ||
119 | 50 | --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect | ||
120 | 51 | --error 0,2013 | ||
121 | 52 | START SLAVE; | ||
122 | 53 | --source include/wait_until_disconnected.inc | ||
123 | 54 | --enable_reconnect | ||
124 | 55 | |||
125 | 56 | --let $rpl_server_number= 2 | ||
126 | 57 | --source include/rpl_start_server.inc | ||
127 | 58 | --source include/start_slave.inc | ||
128 | 59 | connection master; | ||
129 | 60 | sync_slave_with_master; | ||
130 | 61 | SELECT COUNT(*) FROM t1; | ||
131 | 62 | |||
132 | 63 | # | ||
133 | 64 | # Test the rollback of slave position stored in the InnoDB trx header. | ||
134 | 65 | # | ||
135 | 66 | STOP SLAVE; | ||
136 | 67 | --source include/wait_for_slave_to_stop.inc | ||
137 | 68 | |||
138 | 69 | connection master; | ||
139 | 70 | INSERT INTO t1 VALUES(); | ||
140 | 71 | SELECT COUNT(*) FROM t1; | ||
141 | 72 | |||
142 | 73 | connection slave; | ||
143 | 74 | SET GLOBAL debug="+d,crash_innodb_after_prepare"; | ||
144 | 75 | --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect | ||
145 | 76 | --error 0,2013 | ||
146 | 77 | START SLAVE; | ||
147 | 78 | --source include/wait_until_disconnected.inc | ||
148 | 79 | --enable_reconnect | ||
149 | 80 | |||
150 | 81 | --let $rpl_server_number= 2 | ||
151 | 82 | --source include/rpl_start_server.inc | ||
152 | 83 | --source include/start_slave.inc | ||
153 | 84 | connection master; | ||
154 | 85 | sync_slave_with_master; | ||
155 | 86 | SELECT COUNT(*) FROM t1; | ||
156 | 87 | |||
157 | 88 | # | ||
158 | 89 | # Test crash with XA transaction recovery (bug 1012715) | ||
159 | 90 | # | ||
160 | 91 | STOP SLAVE; | ||
161 | 92 | --source include/wait_for_slave_to_stop.inc | ||
162 | 93 | connection master; | ||
163 | 94 | INSERT INTO t1 VALUES(); | ||
164 | 95 | SELECT COUNT(*) FROM t1; | ||
165 | 96 | |||
166 | 97 | connection slave; | ||
167 | 98 | SET GLOBAL debug="+d,crash_innodb_before_commit"; | ||
168 | 99 | --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect | ||
169 | 100 | --error 0,2013 | ||
170 | 101 | START SLAVE; | ||
171 | 102 | --source include/wait_until_disconnected.inc | ||
172 | 103 | --enable_reconnect | ||
173 | 104 | |||
174 | 105 | --let $rpl_server_number= 2 | ||
175 | 106 | --source include/rpl_start_server.inc | ||
176 | 107 | --source include/start_slave.inc | ||
177 | 108 | SELECT COUNT(*) FROM t1; | ||
178 | 109 | |||
179 | 110 | # | ||
180 | 111 | # Cleanup | ||
181 | 112 | # | ||
182 | 113 | |||
183 | 114 | connection master; | ||
184 | 115 | DROP TABLE t1; | ||
185 | 116 | |||
186 | 117 | --source include/rpl_end.inc | ||
187 | 0 | 118 | ||
188 | === modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc' | |||
189 | --- Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-08-07 06:10:00 +0000 | |||
190 | +++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-08-17 02:53:37 +0000 | |||
191 | @@ -2483,6 +2483,118 @@ | |||
192 | 2483 | reset_template(prebuilt); | 2483 | reset_template(prebuilt); |
193 | 2484 | } | 2484 | } |
194 | 2485 | 2485 | ||
195 | 2486 | /* The last read master log coordinates in the slave info file */ | ||
196 | 2487 | static char master_log_fname[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN] = ""; | ||
197 | 2488 | static int master_log_pos; | ||
198 | 2489 | /* The slave relay log coordinates in the slave info file after startup */ | ||
199 | 2490 | static char original_relay_log_fname[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN] = ""; | ||
200 | 2491 | static int original_relay_log_pos; | ||
201 | 2492 | /* The master log coordinates in the slave info file after startup */ | ||
202 | 2493 | static char original_master_log_fname[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN] = ""; | ||
203 | 2494 | static int original_master_log_pos; | ||
204 | 2495 | |||
205 | 2496 | /*****************************************************************//** | ||
206 | 2497 | Overwrites the MySQL relay log info file with the current master and relay log | ||
207 | 2498 | coordinates from InnoDB. Skips overwrite if the master log position did not | ||
208 | 2499 | change from the last overwrite. If the InnoDB master log position is equal | ||
209 | 2500 | to position that was read from the info file on startup before any overwrites, | ||
210 | 2501 | restores the original positions. */ | ||
211 | 2502 | static | ||
212 | 2503 | void | ||
213 | 2504 | innobase_do_overwrite_relay_log_info(void) | ||
214 | 2505 | /*======================================*/ | ||
215 | 2506 | { | ||
216 | 2507 | char info_fname[FN_REFLEN]; | ||
217 | 2508 | File info_fd = -1; | ||
218 | 2509 | int error = 0; | ||
219 | 2510 | char buff[FN_REFLEN*2+22*2+4]; | ||
220 | 2511 | char *relay_info_log_pos; | ||
221 | 2512 | size_t buf_len; | ||
222 | 2513 | |||
223 | 2514 | if (master_log_fname[0] == '\0') { | ||
224 | 2515 | fprintf(stderr, | ||
225 | 2516 | "InnoDB: something wrong with relay-log.info. " | ||
226 | 2517 | "InnoDB will not overwrite it.\n"); | ||
227 | 2518 | return; | ||
228 | 2519 | } | ||
229 | 2520 | |||
230 | 2521 | if (strcmp(master_log_fname, trx_sys_mysql_master_log_name) == 0 | ||
231 | 2522 | && master_log_pos == trx_sys_mysql_master_log_pos) { | ||
232 | 2523 | fprintf(stderr, | ||
233 | 2524 | "InnoDB: InnoDB and relay-log.info are synchronized. " | ||
234 | 2525 | "InnoDB will not overwrite it.\n"); | ||
235 | 2526 | return; | ||
236 | 2527 | } | ||
237 | 2528 | |||
238 | 2529 | /* If we overwrite the file back to the original master log position, | ||
239 | 2530 | restore the original relay log position too. This is required because | ||
240 | 2531 | we might have rolled back a prepared transaction and restored the | ||
241 | 2532 | original master log position from the InnoDB trx sys header, but the | ||
242 | 2533 | corresponding relay log position points to an already-purged file. */ | ||
243 | 2534 | if (strcmp(original_master_log_fname, trx_sys_mysql_master_log_name) | ||
244 | 2535 | == 0 | ||
245 | 2536 | && (original_master_log_pos == trx_sys_mysql_master_log_pos)) { | ||
246 | 2537 | |||
247 | 2538 | strncpy(trx_sys_mysql_relay_log_name, original_relay_log_fname, | ||
248 | 2539 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | ||
249 | 2540 | trx_sys_mysql_relay_log_pos = original_relay_log_pos; | ||
250 | 2541 | } | ||
251 | 2542 | |||
252 | 2543 | fn_format(info_fname, relay_log_info_file, mysql_data_home, "", | ||
253 | 2544 | MY_UNPACK_FILENAME | MY_RETURN_REAL_PATH); | ||
254 | 2545 | |||
255 | 2546 | if (access(info_fname, F_OK)) { | ||
256 | 2547 | /* File does not exist */ | ||
257 | 2548 | error = 1; | ||
258 | 2549 | goto skip_overwrite; | ||
259 | 2550 | } | ||
260 | 2551 | |||
261 | 2552 | /* File exists */ | ||
262 | 2553 | info_fd = my_open(info_fname, O_RDWR|O_BINARY, MYF(MY_WME)); | ||
263 | 2554 | if (info_fd < 0) { | ||
264 | 2555 | error = 1; | ||
265 | 2556 | goto skip_overwrite; | ||
266 | 2557 | } | ||
267 | 2558 | |||
268 | 2559 | relay_info_log_pos = strmov(buff, trx_sys_mysql_relay_log_name); | ||
269 | 2560 | *relay_info_log_pos ++= '\n'; | ||
270 | 2561 | relay_info_log_pos = longlong2str(trx_sys_mysql_relay_log_pos, | ||
271 | 2562 | relay_info_log_pos, 10); | ||
272 | 2563 | *relay_info_log_pos ++= '\n'; | ||
273 | 2564 | relay_info_log_pos = strmov(relay_info_log_pos, | ||
274 | 2565 | trx_sys_mysql_master_log_name); | ||
275 | 2566 | *relay_info_log_pos ++= '\n'; | ||
276 | 2567 | relay_info_log_pos = longlong2str(trx_sys_mysql_master_log_pos, | ||
277 | 2568 | relay_info_log_pos, 10); | ||
278 | 2569 | *relay_info_log_pos = '\n'; | ||
279 | 2570 | |||
280 | 2571 | buf_len = (relay_info_log_pos - buff) + 1; | ||
281 | 2572 | if (my_write(info_fd, (uchar *)buff, buf_len, MY_WME) != buf_len) { | ||
282 | 2573 | error = 1; | ||
283 | 2574 | } else if (my_sync(info_fd, MY_WME)) { | ||
284 | 2575 | error = 1; | ||
285 | 2576 | } | ||
286 | 2577 | |||
287 | 2578 | if (info_fd >= 0) { | ||
288 | 2579 | my_close(info_fd, MYF(0)); | ||
289 | 2580 | } | ||
290 | 2581 | |||
291 | 2582 | strncpy(master_log_fname, trx_sys_mysql_relay_log_name, | ||
292 | 2583 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | ||
293 | 2584 | master_log_pos = trx_sys_mysql_master_log_pos; | ||
294 | 2585 | |||
295 | 2586 | skip_overwrite: | ||
296 | 2587 | if (error) { | ||
297 | 2588 | fprintf(stderr, | ||
298 | 2589 | "InnoDB: ERROR: error occured during overwriting " | ||
299 | 2590 | "relay-log.info.\n"); | ||
300 | 2591 | } else { | ||
301 | 2592 | fprintf(stderr, | ||
302 | 2593 | "InnoDB: relay-log.info was overwritten.\n"); | ||
303 | 2594 | } | ||
304 | 2595 | } | ||
305 | 2596 | |||
306 | 2597 | |||
307 | 2486 | /*********************************************************************//** | 2598 | /*********************************************************************//** |
308 | 2487 | Opens an InnoDB database. | 2599 | Opens an InnoDB database. |
309 | 2488 | @return 0 on success, error code on failure */ | 2600 | @return 0 on success, error code on failure */ |
310 | @@ -2617,12 +2729,13 @@ | |||
311 | 2617 | #ifdef HAVE_REPLICATION | 2729 | #ifdef HAVE_REPLICATION |
312 | 2618 | #ifdef MYSQL_SERVER | 2730 | #ifdef MYSQL_SERVER |
313 | 2619 | /* read master log position from relay-log.info if exists */ | 2731 | /* read master log position from relay-log.info if exists */ |
316 | 2620 | char fname[FN_REFLEN+128]; | 2732 | char info_fname[FN_REFLEN]; |
317 | 2621 | int pos; | 2733 | char relay_log_fname[TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN]; |
318 | 2734 | int relay_log_pos; | ||
319 | 2622 | int info_fd; | 2735 | int info_fd; |
320 | 2623 | IO_CACHE info_file; | 2736 | IO_CACHE info_file; |
321 | 2624 | 2737 | ||
323 | 2625 | fname[0] = '\0'; | 2738 | info_fname[0] = '\0'; |
324 | 2626 | 2739 | ||
325 | 2627 | if(innobase_overwrite_relay_log_info) { | 2740 | if(innobase_overwrite_relay_log_info) { |
326 | 2628 | 2741 | ||
327 | @@ -2631,13 +2744,14 @@ | |||
328 | 2631 | " Updates by other storage engines may not be synchronized.\n"); | 2744 | " Updates by other storage engines may not be synchronized.\n"); |
329 | 2632 | 2745 | ||
330 | 2633 | bzero((char*) &info_file, sizeof(info_file)); | 2746 | bzero((char*) &info_file, sizeof(info_file)); |
332 | 2634 | fn_format(fname, relay_log_info_file, mysql_data_home, "", 4+32); | 2747 | fn_format(info_fname, relay_log_info_file, mysql_data_home, "", 4+32); |
333 | 2635 | 2748 | ||
334 | 2636 | int error=0; | 2749 | int error=0; |
335 | 2637 | 2750 | ||
337 | 2638 | if (!access(fname,F_OK)) { | 2751 | if (!access(info_fname,F_OK)) { |
338 | 2639 | /* exist */ | 2752 | /* exist */ |
340 | 2640 | if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0) { | 2753 | if ((info_fd = my_open(info_fname, O_RDWR | O_BINARY, |
341 | 2754 | MYF(MY_WME))) < 0) { | ||
342 | 2641 | error=1; | 2755 | error=1; |
343 | 2642 | } else if (init_io_cache(&info_file, info_fd, IO_SIZE*2, | 2756 | } else if (init_io_cache(&info_file, info_fd, IO_SIZE*2, |
344 | 2643 | READ_CACHE, 0L, 0, MYF(MY_WME))) { | 2757 | READ_CACHE, 0L, 0, MYF(MY_WME))) { |
345 | @@ -2648,16 +2762,18 @@ | |||
346 | 2648 | relay_info_error: | 2762 | relay_info_error: |
347 | 2649 | if (info_fd >= 0) | 2763 | if (info_fd >= 0) |
348 | 2650 | my_close(info_fd, MYF(0)); | 2764 | my_close(info_fd, MYF(0)); |
350 | 2651 | fname[0] = '\0'; | 2765 | master_log_fname[0] = '\0'; |
351 | 2652 | goto skip_relay; | 2766 | goto skip_relay; |
352 | 2653 | } | 2767 | } |
353 | 2654 | } else { | 2768 | } else { |
355 | 2655 | fname[0] = '\0'; | 2769 | master_log_fname[0] = '\0'; |
356 | 2656 | goto skip_relay; | 2770 | goto skip_relay; |
357 | 2657 | } | 2771 | } |
358 | 2658 | 2772 | ||
361 | 2659 | if (init_strvar_from_file(fname, sizeof(fname), &info_file, "") || /* dummy (it is relay-log) */ | 2773 | if (init_strvar_from_file(relay_log_fname, sizeof(relay_log_fname), |
362 | 2660 | init_intvar_from_file(&pos, &info_file, BIN_LOG_HEADER_SIZE)) { | 2774 | &info_file, "") |
363 | 2775 | || /* dummy (it is relay-log) */ init_intvar_from_file( | ||
364 | 2776 | &relay_log_pos, &info_file, BIN_LOG_HEADER_SIZE)) { | ||
365 | 2661 | end_io_cache(&info_file); | 2777 | end_io_cache(&info_file); |
366 | 2662 | error=1; | 2778 | error=1; |
367 | 2663 | goto relay_info_error; | 2779 | goto relay_info_error; |
368 | @@ -2666,13 +2782,19 @@ | |||
369 | 2666 | fprintf(stderr, | 2782 | fprintf(stderr, |
370 | 2667 | "InnoDB: relay-log.info is detected.\n" | 2783 | "InnoDB: relay-log.info is detected.\n" |
371 | 2668 | "InnoDB: relay log: position %u, file name %s\n", | 2784 | "InnoDB: relay log: position %u, file name %s\n", |
379 | 2669 | pos, fname); | 2785 | relay_log_pos, relay_log_fname); |
380 | 2670 | 2786 | ||
381 | 2671 | strncpy(trx_sys_mysql_relay_log_name, fname, TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | 2787 | strncpy(trx_sys_mysql_relay_log_name, relay_log_fname, |
382 | 2672 | trx_sys_mysql_relay_log_pos = (ib_int64_t) pos; | 2788 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); |
383 | 2673 | 2789 | trx_sys_mysql_relay_log_pos = (ib_int64_t) relay_log_pos; | |
384 | 2674 | if (init_strvar_from_file(fname, sizeof(fname), &info_file, "") || | 2790 | |
385 | 2675 | init_intvar_from_file(&pos, &info_file, 0)) { | 2791 | strncpy(original_relay_log_fname, relay_log_fname, |
386 | 2792 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | ||
387 | 2793 | original_relay_log_pos = relay_log_pos; | ||
388 | 2794 | |||
389 | 2795 | if (init_strvar_from_file(master_log_fname, sizeof(master_log_fname), | ||
390 | 2796 | &info_file, "") | ||
391 | 2797 | || init_intvar_from_file(&master_log_pos, &info_file, 0)) { | ||
392 | 2676 | end_io_cache(&info_file); | 2798 | end_io_cache(&info_file); |
393 | 2677 | error=1; | 2799 | error=1; |
394 | 2678 | goto relay_info_error; | 2800 | goto relay_info_error; |
395 | @@ -2680,10 +2802,15 @@ | |||
396 | 2680 | 2802 | ||
397 | 2681 | fprintf(stderr, | 2803 | fprintf(stderr, |
398 | 2682 | "InnoDB: master log: position %u, file name %s\n", | 2804 | "InnoDB: master log: position %u, file name %s\n", |
403 | 2683 | pos, fname); | 2805 | master_log_pos, master_log_fname); |
404 | 2684 | 2806 | ||
405 | 2685 | strncpy(trx_sys_mysql_master_log_name, fname, TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | 2807 | strncpy(trx_sys_mysql_master_log_name, master_log_fname, |
406 | 2686 | trx_sys_mysql_master_log_pos = (ib_int64_t) pos; | 2808 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); |
407 | 2809 | trx_sys_mysql_master_log_pos = (ib_int64_t) master_log_pos; | ||
408 | 2810 | |||
409 | 2811 | strncpy(original_master_log_fname, master_log_fname, | ||
410 | 2812 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | ||
411 | 2813 | original_master_log_pos = master_log_pos; | ||
412 | 2687 | 2814 | ||
413 | 2688 | end_io_cache(&info_file); | 2815 | end_io_cache(&info_file); |
414 | 2689 | if (info_fd >= 0) | 2816 | if (info_fd >= 0) |
415 | @@ -3017,75 +3144,9 @@ | |||
416 | 3017 | goto mem_free_and_error; | 3144 | goto mem_free_and_error; |
417 | 3018 | } | 3145 | } |
418 | 3019 | 3146 | ||
419 | 3020 | #ifdef HAVE_REPLICATION | ||
420 | 3021 | #ifdef MYSQL_SERVER | ||
421 | 3022 | if(innobase_overwrite_relay_log_info) { | 3147 | if(innobase_overwrite_relay_log_info) { |
488 | 3023 | /* If InnoDB progressed from relay-log.info, overwrite it */ | 3148 | innobase_do_overwrite_relay_log_info(); |
489 | 3024 | if (fname[0] == '\0') { | 3149 | } |
424 | 3025 | fprintf(stderr, | ||
425 | 3026 | "InnoDB: Something is wrong with the file relay-info.log. InnoDB will not overwrite it.\n"); | ||
426 | 3027 | } else if (0 != strcmp(fname, trx_sys_mysql_master_log_name) | ||
427 | 3028 | || pos != trx_sys_mysql_master_log_pos) { | ||
428 | 3029 | /* Overwrite relay-log.info */ | ||
429 | 3030 | bzero((char*) &info_file, sizeof(info_file)); | ||
430 | 3031 | fn_format(fname, relay_log_info_file, mysql_data_home, "", 4+32); | ||
431 | 3032 | |||
432 | 3033 | int error = 0; | ||
433 | 3034 | |||
434 | 3035 | if (!access(fname,F_OK)) { | ||
435 | 3036 | /* exist */ | ||
436 | 3037 | if ((info_fd = my_open(fname, O_RDWR|O_BINARY, MYF(MY_WME))) < 0) { | ||
437 | 3038 | error = 1; | ||
438 | 3039 | } else if (init_io_cache(&info_file, info_fd, IO_SIZE*2, | ||
439 | 3040 | WRITE_CACHE, 0L, 0, MYF(MY_WME))) { | ||
440 | 3041 | error = 1; | ||
441 | 3042 | } | ||
442 | 3043 | |||
443 | 3044 | if (error) { | ||
444 | 3045 | if (info_fd >= 0) | ||
445 | 3046 | my_close(info_fd, MYF(0)); | ||
446 | 3047 | goto skip_overwrite; | ||
447 | 3048 | } | ||
448 | 3049 | } else { | ||
449 | 3050 | error = 1; | ||
450 | 3051 | goto skip_overwrite; | ||
451 | 3052 | } | ||
452 | 3053 | |||
453 | 3054 | char buff[FN_REFLEN*2+22*2+4], *pos; | ||
454 | 3055 | |||
455 | 3056 | my_b_seek(&info_file, 0L); | ||
456 | 3057 | pos=strmov(buff, trx_sys_mysql_relay_log_name); | ||
457 | 3058 | *pos++='\n'; | ||
458 | 3059 | pos=longlong2str(trx_sys_mysql_relay_log_pos, pos, 10); | ||
459 | 3060 | *pos++='\n'; | ||
460 | 3061 | pos=strmov(pos, trx_sys_mysql_master_log_name); | ||
461 | 3062 | *pos++='\n'; | ||
462 | 3063 | pos=longlong2str(trx_sys_mysql_master_log_pos, pos, 10); | ||
463 | 3064 | *pos='\n'; | ||
464 | 3065 | |||
465 | 3066 | if (my_b_write(&info_file, (uchar*) buff, (size_t) (pos-buff)+1)) | ||
466 | 3067 | error = 1; | ||
467 | 3068 | if (flush_io_cache(&info_file)) | ||
468 | 3069 | error = 1; | ||
469 | 3070 | |||
470 | 3071 | end_io_cache(&info_file); | ||
471 | 3072 | if (info_fd >= 0) | ||
472 | 3073 | my_close(info_fd, MYF(0)); | ||
473 | 3074 | skip_overwrite: | ||
474 | 3075 | if (error) { | ||
475 | 3076 | fprintf(stderr, | ||
476 | 3077 | "InnoDB: ERROR: An error occurred while overwriting relay-log.info.\n"); | ||
477 | 3078 | } else { | ||
478 | 3079 | fprintf(stderr, | ||
479 | 3080 | "InnoDB: The file relay-log.info was successfully overwritten.\n"); | ||
480 | 3081 | } | ||
481 | 3082 | } else { | ||
482 | 3083 | fprintf(stderr, | ||
483 | 3084 | "InnoDB: InnoDB and relay-log.info are synchronized. InnoDB will not overwrite it.\n"); | ||
484 | 3085 | } | ||
485 | 3086 | } | ||
486 | 3087 | #endif /* MYSQL_SERVER */ | ||
487 | 3088 | #endif /* HAVE_REPLICATION */ | ||
490 | 3089 | 3150 | ||
491 | 3090 | innobase_old_blocks_pct = buf_LRU_old_ratio_update( | 3151 | innobase_old_blocks_pct = buf_LRU_old_ratio_update( |
492 | 3091 | innobase_old_blocks_pct, TRUE); | 3152 | innobase_old_blocks_pct, TRUE); |
493 | @@ -3191,6 +3252,32 @@ | |||
494 | 3191 | | HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE); | 3252 | | HA_INPLACE_ADD_PK_INDEX_NO_READ_WRITE); |
495 | 3192 | } | 3253 | } |
496 | 3193 | 3254 | ||
497 | 3255 | /****************************************************************//** | ||
498 | 3256 | Copy the current replication position from MySQL to a transaction. */ | ||
499 | 3257 | static | ||
500 | 3258 | void | ||
501 | 3259 | innobase_copy_repl_coords_to_trx( | ||
502 | 3260 | /*=============================*/ | ||
503 | 3261 | const THD* thd, /*!< in: thread handle */ | ||
504 | 3262 | trx_t* trx) /*!< in/out: transaction */ | ||
505 | 3263 | { | ||
506 | 3264 | if (thd && thd->slave_thread) { | ||
507 | 3265 | const Relay_log_info* rli = &active_mi->rli; | ||
508 | 3266 | |||
509 | 3267 | trx->mysql_master_log_file_name | ||
510 | 3268 | = rli->group_master_log_name; | ||
511 | 3269 | trx->mysql_master_log_pos | ||
512 | 3270 | = ((ib_int64_t)rli->group_master_log_pos | ||
513 | 3271 | + ((ib_int64_t) | ||
514 | 3272 | rli->future_event_relay_log_pos | ||
515 | 3273 | - (ib_int64_t)rli->group_relay_log_pos)); | ||
516 | 3274 | trx->mysql_relay_log_file_name | ||
517 | 3275 | = rli->group_relay_log_name; | ||
518 | 3276 | trx->mysql_relay_log_pos | ||
519 | 3277 | = (ib_int64_t)rli->future_event_relay_log_pos; | ||
520 | 3278 | } | ||
521 | 3279 | } | ||
522 | 3280 | |||
523 | 3194 | /*****************************************************************//** | 3281 | /*****************************************************************//** |
524 | 3195 | Commits a transaction in an InnoDB database. */ | 3282 | Commits a transaction in an InnoDB database. */ |
525 | 3196 | static | 3283 | static |
526 | @@ -3200,25 +3287,12 @@ | |||
527 | 3200 | trx_t* trx) /*!< in: transaction handle */ | 3287 | trx_t* trx) /*!< in: transaction handle */ |
528 | 3201 | { | 3288 | { |
529 | 3202 | if (trx_is_started(trx)) { | 3289 | if (trx_is_started(trx)) { |
549 | 3203 | #ifdef HAVE_REPLICATION | 3290 | |
550 | 3204 | #ifdef MYSQL_SERVER | 3291 | /* Save the current replication position for write to trx sys |
551 | 3205 | THD *thd=current_thd; | 3292 | header for undo purposes, see the comment at corresponding call |
552 | 3206 | 3293 | at innobase_xa_prepare(). */ | |
553 | 3207 | if (thd && thd->slave_thread) { | 3294 | |
554 | 3208 | /* Update the replication position info inside InnoDB */ | 3295 | innobase_copy_repl_coords_to_trx(current_thd, trx); |
536 | 3209 | trx->mysql_master_log_file_name | ||
537 | 3210 | = active_mi->rli.group_master_log_name; | ||
538 | 3211 | trx->mysql_master_log_pos | ||
539 | 3212 | = ((ib_int64_t)active_mi->rli.group_master_log_pos + | ||
540 | 3213 | ((ib_int64_t)active_mi->rli.future_event_relay_log_pos - | ||
541 | 3214 | (ib_int64_t)active_mi->rli.group_relay_log_pos)); | ||
542 | 3215 | trx->mysql_relay_log_file_name | ||
543 | 3216 | = active_mi->rli.group_relay_log_name; | ||
544 | 3217 | trx->mysql_relay_log_pos | ||
545 | 3218 | = (ib_int64_t)active_mi->rli.future_event_relay_log_pos; | ||
546 | 3219 | } | ||
547 | 3220 | #endif /* MYSQL_SERVER */ | ||
548 | 3221 | #endif /* HAVE_REPLICATION */ | ||
555 | 3222 | 3296 | ||
556 | 3223 | trx_commit_for_mysql(trx); | 3297 | trx_commit_for_mysql(trx); |
557 | 3224 | } | 3298 | } |
558 | @@ -3436,6 +3510,9 @@ | |||
559 | 3436 | if (all | 3510 | if (all |
560 | 3437 | || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { | 3511 | || (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { |
561 | 3438 | 3512 | ||
562 | 3513 | DBUG_EXECUTE_IF("crash_innodb_before_commit", | ||
563 | 3514 | DBUG_SUICIDE();); | ||
564 | 3515 | |||
565 | 3439 | /* We were instructed to commit the whole transaction, or | 3516 | /* We were instructed to commit the whole transaction, or |
566 | 3440 | this is an SQL statement end and autocommit is on */ | 3517 | this is an SQL statement end and autocommit is on */ |
567 | 3441 | 3518 | ||
568 | @@ -11369,7 +11446,27 @@ | |||
569 | 11369 | 11446 | ||
570 | 11370 | ut_ad(trx_is_registered_for_2pc(trx)); | 11447 | ut_ad(trx_is_registered_for_2pc(trx)); |
571 | 11371 | 11448 | ||
572 | 11449 | /* Update the replication position info in current trx. This | ||
573 | 11450 | is different from the binlog position update that happens | ||
574 | 11451 | during XA COMMIT. In contrast to that, the slave position is | ||
575 | 11452 | an actual part of the changes made by this transaction and thus | ||
576 | 11453 | must be updated in the XA PREPARE stage. Since the trx sys | ||
577 | 11454 | header page changes are not undo-logged, again store this | ||
578 | 11455 | position in a different field in the XA COMMIT stage, so that | ||
579 | 11456 | it might be used in case of rollbacks. */ | ||
580 | 11457 | |||
581 | 11458 | /* Since currently there might be only one slave SQL thread, we | ||
582 | 11459 | don't need to take any precautions (e.g. prepare_commit_mutex) | ||
583 | 11460 | to ensure position ordering. Revisit this in 5.6 which has | ||
584 | 11461 | both the multi-threaded replication to cause us problems and | ||
585 | 11462 | the group commit to solve them. */ | ||
586 | 11463 | |||
587 | 11464 | innobase_copy_repl_coords_to_trx(thd, trx); | ||
588 | 11465 | |||
589 | 11372 | error = (int) trx_prepare_for_mysql(trx); | 11466 | error = (int) trx_prepare_for_mysql(trx); |
590 | 11467 | |||
591 | 11468 | DBUG_EXECUTE_IF("crash_innodb_after_prepare", | ||
592 | 11469 | DBUG_SUICIDE();); | ||
593 | 11373 | } else { | 11470 | } else { |
594 | 11374 | /* We just mark the SQL statement ended and do not do a | 11471 | /* We just mark the SQL statement ended and do not do a |
595 | 11375 | transaction prepare */ | 11472 | transaction prepare */ |
596 | @@ -11491,6 +11588,22 @@ | |||
597 | 11491 | if (trx) { | 11588 | if (trx) { |
598 | 11492 | int ret = innobase_rollback_trx(trx); | 11589 | int ret = innobase_rollback_trx(trx); |
599 | 11493 | trx_free_for_background(trx); | 11590 | trx_free_for_background(trx); |
600 | 11591 | |||
601 | 11592 | if (innobase_overwrite_relay_log_info) { | ||
602 | 11593 | |||
603 | 11594 | /* On rollback of a prepared transaction revert the | ||
604 | 11595 | current slave positions to the ones recorded by the | ||
605 | 11596 | last COMMITTed transaction. This has an effect of | ||
606 | 11597 | undoing the position change caused by the transaction | ||
607 | 11598 | being rolled back. Assumes single-threaded slave SQL | ||
608 | 11599 | thread. If the server has non-master write traffic | ||
609 | 11600 | with XA rollbacks, this will cause additional spurious | ||
610 | 11601 | slave info log overwrites, which should be harmless. */ | ||
611 | 11602 | |||
612 | 11603 | trx_sys_print_committed_mysql_master_log_pos(); | ||
613 | 11604 | innobase_do_overwrite_relay_log_info(); | ||
614 | 11605 | } | ||
615 | 11606 | |||
616 | 11494 | return(ret); | 11607 | return(ret); |
617 | 11495 | } else { | 11608 | } else { |
618 | 11496 | return(XAER_NOTA); | 11609 | return(XAER_NOTA); |
619 | 11497 | 11610 | ||
620 | === modified file 'Percona-Server/storage/innobase/include/trx0sys.h' | |||
621 | --- Percona-Server/storage/innobase/include/trx0sys.h 2012-08-07 06:10:00 +0000 | |||
622 | +++ Percona-Server/storage/innobase/include/trx0sys.h 2012-08-17 02:53:37 +0000 | |||
623 | @@ -342,6 +342,14 @@ | |||
624 | 342 | trx_sys_print_mysql_binlog_offset(void); | 342 | trx_sys_print_mysql_binlog_offset(void); |
625 | 343 | /*===================================*/ | 343 | /*===================================*/ |
626 | 344 | /*****************************************************************//** | 344 | /*****************************************************************//** |
627 | 345 | Prints to stderr the MySQL master log offset info in the trx system header | ||
628 | 346 | COMMIT set of fields if the magic number shows it valid and stores it | ||
629 | 347 | in global variables. */ | ||
630 | 348 | UNIV_INTERN | ||
631 | 349 | void | ||
632 | 350 | trx_sys_print_committed_mysql_master_log_pos(void); | ||
633 | 351 | /*==============================================*/ | ||
634 | 352 | /*****************************************************************//** | ||
635 | 345 | Prints to stderr the MySQL master log offset info in the trx system header if | 353 | Prints to stderr the MySQL master log offset info in the trx system header if |
636 | 346 | the magic number shows it valid. */ | 354 | the magic number shows it valid. */ |
637 | 347 | UNIV_INTERN | 355 | UNIV_INTERN |
638 | @@ -534,10 +542,16 @@ | |||
639 | 534 | //# error "UNIV_PAGE_SIZE < 4096" | 542 | //# error "UNIV_PAGE_SIZE < 4096" |
640 | 535 | //#endif | 543 | //#endif |
641 | 536 | /** The offset of the MySQL replication info in the trx system header; | 544 | /** The offset of the MySQL replication info in the trx system header; |
643 | 537 | this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */ | 545 | this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below. These are |
644 | 546 | written at prepare time and are the main copy. */ | ||
645 | 538 | #define TRX_SYS_MYSQL_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000) | 547 | #define TRX_SYS_MYSQL_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 2000) |
646 | 539 | #define TRX_SYS_MYSQL_RELAY_LOG_INFO (UNIV_PAGE_SIZE - 1500) | 548 | #define TRX_SYS_MYSQL_RELAY_LOG_INFO (UNIV_PAGE_SIZE - 1500) |
647 | 540 | 549 | ||
648 | 550 | /** The copy of the above which is made at transaction COMMIT time. If binlog | ||
649 | 551 | crash recovery rollbacks a PREPAREd transaction, they are copied back. */ | ||
650 | 552 | #define TRX_SYS_COMMIT_MASTER_LOG_INFO (UNIV_PAGE_SIZE - 3000) | ||
651 | 553 | #define TRX_SYS_COMMIT_RELAY_LOG_INFO (UNIV_PAGE_SIZE - 2500) | ||
652 | 554 | |||
653 | 541 | /** The offset of the MySQL binlog offset info in the trx system header */ | 555 | /** The offset of the MySQL binlog offset info in the trx system header */ |
654 | 542 | #define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000) | 556 | #define TRX_SYS_MYSQL_LOG_INFO (UNIV_PAGE_SIZE - 1000) |
655 | 543 | #define TRX_SYS_MYSQL_LOG_MAGIC_N_FLD 0 /*!< magic number which is | 557 | #define TRX_SYS_MYSQL_LOG_MAGIC_N_FLD 0 /*!< magic number which is |
656 | 544 | 558 | ||
657 | === modified file 'Percona-Server/storage/innobase/trx/trx0sys.c' | |||
658 | --- Percona-Server/storage/innobase/trx/trx0sys.c 2012-08-07 06:10:00 +0000 | |||
659 | +++ Percona-Server/storage/innobase/trx/trx0sys.c 2012-08-17 02:53:37 +0000 | |||
660 | @@ -959,8 +959,31 @@ | |||
661 | 959 | } | 959 | } |
662 | 960 | 960 | ||
663 | 961 | /*****************************************************************//** | 961 | /*****************************************************************//** |
666 | 962 | Prints to stderr the MySQL master log offset info in the trx system header if | 962 | Reads the log coordinates at the given offset in the trx sys header. */ |
667 | 963 | the magic number shows it valid. */ | 963 | static |
668 | 964 | void | ||
669 | 965 | trx_sys_read_log_pos( | ||
670 | 966 | /*=================*/ | ||
671 | 967 | const trx_sysf_t* sys_header, /*!< in: the trx sys header */ | ||
672 | 968 | uint header_offset, /*!< in: coord offset in the | ||
673 | 969 | header */ | ||
674 | 970 | char* log_fn, /*!< out: the log file name */ | ||
675 | 971 | ib_int64_t* log_pos) /*!< out: the log poistion */ | ||
676 | 972 | { | ||
677 | 973 | ut_memcpy(log_fn, sys_header + header_offset + TRX_SYS_MYSQL_LOG_NAME, | ||
678 | 974 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | ||
679 | 975 | |||
680 | 976 | *log_pos = | ||
681 | 977 | (((ib_int64_t)mach_read_from_4(sys_header + header_offset | ||
682 | 978 | + TRX_SYS_MYSQL_LOG_OFFSET_HIGH)) << 32) | ||
683 | 979 | + mach_read_from_4(sys_header + header_offset | ||
684 | 980 | + TRX_SYS_MYSQL_LOG_OFFSET_LOW); | ||
685 | 981 | } | ||
686 | 982 | |||
687 | 983 | /*****************************************************************//** | ||
688 | 984 | Prints to stderr the MySQL master log offset info in the trx system header | ||
689 | 985 | PREPARE set of fields if the magic number shows it valid and stores it | ||
690 | 986 | in global variables. */ | ||
691 | 964 | UNIV_INTERN | 987 | UNIV_INTERN |
692 | 965 | void | 988 | void |
693 | 966 | trx_sys_print_mysql_master_log_pos(void) | 989 | trx_sys_print_mysql_master_log_pos(void) |
694 | @@ -982,60 +1005,79 @@ | |||
695 | 982 | return; | 1005 | return; |
696 | 983 | } | 1006 | } |
697 | 984 | 1007 | ||
698 | 985 | fprintf(stderr, | ||
699 | 986 | "InnoDB: In a MySQL replication slave the last" | ||
700 | 987 | " master binlog file\n" | ||
701 | 988 | "InnoDB: position %lu %lu, file name %s\n", | ||
702 | 989 | (ulong) mach_read_from_4(sys_header | ||
703 | 990 | + TRX_SYS_MYSQL_MASTER_LOG_INFO | ||
704 | 991 | + TRX_SYS_MYSQL_LOG_OFFSET_HIGH), | ||
705 | 992 | (ulong) mach_read_from_4(sys_header | ||
706 | 993 | + TRX_SYS_MYSQL_MASTER_LOG_INFO | ||
707 | 994 | + TRX_SYS_MYSQL_LOG_OFFSET_LOW), | ||
708 | 995 | sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO | ||
709 | 996 | + TRX_SYS_MYSQL_LOG_NAME); | ||
710 | 997 | |||
711 | 998 | fprintf(stderr, | ||
712 | 999 | "InnoDB: and relay log file\n" | ||
713 | 1000 | "InnoDB: position %lu %lu, file name %s\n", | ||
714 | 1001 | (ulong) mach_read_from_4(sys_header | ||
715 | 1002 | + TRX_SYS_MYSQL_RELAY_LOG_INFO | ||
716 | 1003 | + TRX_SYS_MYSQL_LOG_OFFSET_HIGH), | ||
717 | 1004 | (ulong) mach_read_from_4(sys_header | ||
718 | 1005 | + TRX_SYS_MYSQL_RELAY_LOG_INFO | ||
719 | 1006 | + TRX_SYS_MYSQL_LOG_OFFSET_LOW), | ||
720 | 1007 | sys_header + TRX_SYS_MYSQL_RELAY_LOG_INFO | ||
721 | 1008 | + TRX_SYS_MYSQL_LOG_NAME); | ||
722 | 1009 | |||
723 | 1010 | /* Copy the master log position info to global variables we can | 1008 | /* Copy the master log position info to global variables we can |
724 | 1011 | use in ha_innobase.cc to initialize glob_mi to right values */ | 1009 | use in ha_innobase.cc to initialize glob_mi to right values */ |
752 | 1012 | 1010 | trx_sys_read_log_pos(sys_header, TRX_SYS_MYSQL_MASTER_LOG_INFO, | |
753 | 1013 | ut_memcpy(trx_sys_mysql_master_log_name, | 1011 | trx_sys_mysql_master_log_name, |
754 | 1014 | sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO | 1012 | &trx_sys_mysql_master_log_pos); |
755 | 1015 | + TRX_SYS_MYSQL_LOG_NAME, | 1013 | |
756 | 1016 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | 1014 | trx_sys_read_log_pos(sys_header, TRX_SYS_MYSQL_RELAY_LOG_INFO, |
757 | 1017 | 1015 | trx_sys_mysql_relay_log_name, | |
758 | 1018 | trx_sys_mysql_master_log_pos | 1016 | &trx_sys_mysql_relay_log_pos); |
759 | 1019 | = (((ib_int64_t) mach_read_from_4( | 1017 | |
760 | 1020 | sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO | 1018 | mtr_commit(&mtr); |
761 | 1021 | + TRX_SYS_MYSQL_LOG_OFFSET_HIGH)) << 32) | 1019 | |
762 | 1022 | + ((ib_int64_t) mach_read_from_4( | 1020 | fprintf(stderr, |
763 | 1023 | sys_header + TRX_SYS_MYSQL_MASTER_LOG_INFO | 1021 | "InnoDB: In a MySQL replication slave the last" |
764 | 1024 | + TRX_SYS_MYSQL_LOG_OFFSET_LOW)); | 1022 | " master binlog file\n" |
765 | 1025 | 1023 | "InnoDB: position %llu, file name %s\n", | |
766 | 1026 | ut_memcpy(trx_sys_mysql_relay_log_name, | 1024 | trx_sys_mysql_master_log_pos, |
767 | 1027 | sys_header + TRX_SYS_MYSQL_RELAY_LOG_INFO | 1025 | trx_sys_mysql_master_log_name); |
768 | 1028 | + TRX_SYS_MYSQL_LOG_NAME, | 1026 | |
769 | 1029 | TRX_SYS_MYSQL_MASTER_LOG_NAME_LEN); | 1027 | fprintf(stderr, |
770 | 1030 | 1028 | "InnoDB: and relay log file\n" | |
771 | 1031 | trx_sys_mysql_relay_log_pos | 1029 | "InnoDB: position %llu, file name %s\n", |
772 | 1032 | = (((ib_int64_t) mach_read_from_4( | 1030 | trx_sys_mysql_relay_log_pos, |
773 | 1033 | sys_header + TRX_SYS_MYSQL_RELAY_LOG_INFO | 1031 | trx_sys_mysql_relay_log_name); |
774 | 1034 | + TRX_SYS_MYSQL_LOG_OFFSET_HIGH)) << 32) | 1032 | } |
775 | 1035 | + ((ib_int64_t) mach_read_from_4( | 1033 | |
776 | 1036 | sys_header + TRX_SYS_MYSQL_RELAY_LOG_INFO | 1034 | /*****************************************************************//** |
777 | 1037 | + TRX_SYS_MYSQL_LOG_OFFSET_LOW)); | 1035 | Prints to stderr the MySQL master log offset info in the trx system header |
778 | 1038 | mtr_commit(&mtr); | 1036 | COMMIT set of fields if the magic number shows it valid and stores it |
779 | 1037 | in global variables. */ | ||
780 | 1038 | UNIV_INTERN | ||
781 | 1039 | void | ||
782 | 1040 | trx_sys_print_committed_mysql_master_log_pos(void) | ||
783 | 1041 | /*==============================================*/ | ||
784 | 1042 | { | ||
785 | 1043 | trx_sysf_t* sys_header; | ||
786 | 1044 | mtr_t mtr; | ||
787 | 1045 | |||
788 | 1046 | mtr_start(&mtr); | ||
789 | 1047 | |||
790 | 1048 | sys_header = trx_sysf_get(&mtr); | ||
791 | 1049 | |||
792 | 1050 | if (mach_read_from_4(sys_header + TRX_SYS_COMMIT_MASTER_LOG_INFO | ||
793 | 1051 | + TRX_SYS_MYSQL_LOG_MAGIC_N_FLD) | ||
794 | 1052 | != TRX_SYS_MYSQL_LOG_MAGIC_N) { | ||
795 | 1053 | |||
796 | 1054 | mtr_commit(&mtr); | ||
797 | 1055 | |||
798 | 1056 | return; | ||
799 | 1057 | } | ||
800 | 1058 | |||
801 | 1059 | /* Copy the master log position info to global variables we can | ||
802 | 1060 | use in ha_innobase.cc to initialize glob_mi to right values */ | ||
803 | 1061 | trx_sys_read_log_pos(sys_header, TRX_SYS_COMMIT_MASTER_LOG_INFO, | ||
804 | 1062 | trx_sys_mysql_master_log_name, | ||
805 | 1063 | &trx_sys_mysql_master_log_pos); | ||
806 | 1064 | |||
807 | 1065 | trx_sys_read_log_pos(sys_header, TRX_SYS_COMMIT_RELAY_LOG_INFO, | ||
808 | 1066 | trx_sys_mysql_relay_log_name, | ||
809 | 1067 | &trx_sys_mysql_relay_log_pos); | ||
810 | 1068 | |||
811 | 1069 | mtr_commit(&mtr); | ||
812 | 1070 | |||
813 | 1071 | fprintf(stderr, | ||
814 | 1072 | "InnoDB: In a MySQL replication slave the last" | ||
815 | 1073 | " master binlog file\n" | ||
816 | 1074 | "InnoDB: position %llu, file name %s\n", | ||
817 | 1075 | trx_sys_mysql_master_log_pos, trx_sys_mysql_master_log_name); | ||
818 | 1076 | |||
819 | 1077 | fprintf(stderr, | ||
820 | 1078 | "InnoDB: and relay log file\n" | ||
821 | 1079 | "InnoDB: position %llu, file name %s\n", | ||
822 | 1080 | trx_sys_mysql_relay_log_pos, trx_sys_mysql_relay_log_name); | ||
823 | 1039 | } | 1081 | } |
824 | 1040 | 1082 | ||
825 | 1041 | /****************************************************************//** | 1083 | /****************************************************************//** |
826 | 1042 | 1084 | ||
827 | === modified file 'Percona-Server/storage/innobase/trx/trx0trx.c' | |||
828 | --- Percona-Server/storage/innobase/trx/trx0trx.c 2012-05-10 07:49:14 +0000 | |||
829 | +++ Percona-Server/storage/innobase/trx/trx0trx.c 2012-08-17 02:53:37 +0000 | |||
830 | @@ -939,13 +939,13 @@ | |||
831 | 939 | sys_header, | 939 | sys_header, |
832 | 940 | trx->mysql_relay_log_file_name, | 940 | trx->mysql_relay_log_file_name, |
833 | 941 | trx->mysql_relay_log_pos, | 941 | trx->mysql_relay_log_pos, |
835 | 942 | TRX_SYS_MYSQL_RELAY_LOG_INFO, &mtr); | 942 | TRX_SYS_COMMIT_RELAY_LOG_INFO, &mtr); |
836 | 943 | 943 | ||
837 | 944 | trx_sys_update_mysql_binlog_offset( | 944 | trx_sys_update_mysql_binlog_offset( |
838 | 945 | sys_header, | 945 | sys_header, |
839 | 946 | trx->mysql_master_log_file_name, | 946 | trx->mysql_master_log_file_name, |
840 | 947 | trx->mysql_master_log_pos, | 947 | trx->mysql_master_log_pos, |
842 | 948 | TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr); | 948 | TRX_SYS_COMMIT_MASTER_LOG_INFO, &mtr); |
843 | 949 | 949 | ||
844 | 950 | trx->mysql_master_log_file_name = ""; | 950 | trx->mysql_master_log_file_name = ""; |
845 | 951 | } | 951 | } |
846 | @@ -2051,6 +2051,23 @@ | |||
847 | 2051 | 2051 | ||
848 | 2052 | mutex_exit(&(rseg->mutex)); | 2052 | mutex_exit(&(rseg->mutex)); |
849 | 2053 | 2053 | ||
850 | 2054 | if (trx->mysql_master_log_file_name[0] != '\0') { | ||
851 | 2055 | /* This database server is a MySQL replication slave */ | ||
852 | 2056 | trx_sysf_t* sys_header = trx_sysf_get(&mtr); | ||
853 | 2057 | |||
854 | 2058 | trx_sys_update_mysql_binlog_offset( | ||
855 | 2059 | sys_header, | ||
856 | 2060 | trx->mysql_relay_log_file_name, | ||
857 | 2061 | trx->mysql_relay_log_pos, | ||
858 | 2062 | TRX_SYS_MYSQL_RELAY_LOG_INFO, &mtr); | ||
859 | 2063 | trx_sys_update_mysql_binlog_offset( | ||
860 | 2064 | sys_header, | ||
861 | 2065 | trx->mysql_master_log_file_name, | ||
862 | 2066 | trx->mysql_master_log_pos, | ||
863 | 2067 | TRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr); | ||
864 | 2068 | trx->mysql_master_log_file_name = ""; | ||
865 | 2069 | } | ||
866 | 2070 | |||
867 | 2054 | /*--------------*/ | 2071 | /*--------------*/ |
868 | 2055 | mtr_commit(&mtr); /* This mtr commit makes the | 2072 | mtr_commit(&mtr); /* This mtr commit makes the |
869 | 2056 | transaction prepared in the file-based | 2073 | transaction prepared in the file-based |
Same comments as in the 5.1 MP.