Merge lp:~stewart/percona-server/5.6-doublewrite into lp:percona-server/5.6

Proposed by Stewart Smith
Status: Work in progress
Proposed branch: lp:~stewart/percona-server/5.6-doublewrite
Merge into: lp:percona-server/5.6
Diff against target: 1047 lines (+400/-55)
22 files modified
Percona-Server/mysql-test/suite/innodb/r/percona_innodb_doublewrite_file.result (+13/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file-master.opt (+1/-0)
Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file.test (+12/-0)
Percona-Server/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result (+3/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic-master.opt (+1/-0)
Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test (+2/-0)
Percona-Server/storage/innobase/buf/buf0buf.cc (+2/-1)
Percona-Server/storage/innobase/buf/buf0dblwr.cc (+68/-26)
Percona-Server/storage/innobase/buf/buf0rea.cc (+3/-1)
Percona-Server/storage/innobase/dict/dict0load.cc (+3/-2)
Percona-Server/storage/innobase/fil/fil0fil.cc (+15/-14)
Percona-Server/storage/innobase/fsp/fsp0fsp.cc (+3/-3)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+9/-0)
Percona-Server/storage/innobase/include/mtr0log.ic (+3/-2)
Percona-Server/storage/innobase/include/srv0srv.h (+2/-0)
Percona-Server/storage/innobase/include/srv0start.h (+3/-0)
Percona-Server/storage/innobase/include/trx0sys.h (+24/-0)
Percona-Server/storage/innobase/include/trx0sys.ic (+35/-0)
Percona-Server/storage/innobase/row/row0mysql.cc (+1/-1)
Percona-Server/storage/innobase/srv/srv0srv.cc (+2/-0)
Percona-Server/storage/innobase/srv/srv0start.cc (+163/-0)
Percona-Server/storage/innobase/trx/trx0sys.cc (+32/-5)
To merge this branch: bzr merge lp:~stewart/percona-server/5.6-doublewrite
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Needs Fixing
Review via email: mp+134040@code.launchpad.net

Description of the change

Port innodb_doublewrite_file over to PS 5.6

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

I have logged bugs for the review points that apply to 5.1 and 5.5 too.

I think that for 5.6 everything except for bug 1078181 must be fixed at the MP.

- The main issue with this feature in general is bug 1078181.
- The testcase must do some actual work with data pages. For
  example, the workload must be larger than the log capacity. (bug
  1078187).
- The sys_vars testcase should be a bit more involved. (bug 1078188).
- trx_sys_doublewrite_space() should be used everywhere it
  applies. (bug 1078191).
- buf_dblwr_get space_id arg should have comment.
- buf_dblwr_create_low header should follow InnoDB coding style.
- s/SRV_LOG_SPACE_FIRST_ID/SRV_EXTRA_SYS_SPACE_FIRST_ID in several
  places (bug 1078201).
- Chunk at 410--411 looks wrong: fil_is_user_tablespace_id looks like
  a correct check already.
- Bogus UNIV_LIKELY/UNIV_UNLIKELY (bug 1078206).
- trx_sys_dummy_create() is missing comments and misformatted in
  trx0sys.h.
- For initalizations like at 255--261 and 296--302 personally I prefer
  the ternary operator.
- trx_sys_sys_space has wrong header comment. "Check if a space is a
  system tablespace", likewise for trx_sys_doublewrite_space.
- Style violation at line 766.
- Too long lines at 769+, 780, 822, 825+, 857, 874
- Spurious diff at lines 428, 436, 495, 507, 576.

review: Needs Fixing

Unmerged revisions

310. By Stewart Smith

Port innodb_doublewrite_file to Percona Server 5.6

This was a little bit involved as the doublewrite buffer code has been
refactored in MySQL 5.6 out into buf0dblwr.cc.

One design difference in the 5.6 patch versus 5.5 and before is that where
InnoDB code has needed to be duplicated, I have instead refactored that code
to accept tablespace id as a parameter rather than copy&pasting it. With
this method, we should get merge conflicts if this code is changed upstream,
making it easier to ensure our end result code is correct.

309. By Stewart Smith

merge 5.6.7

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/innodb/r/percona_innodb_doublewrite_file.result'
2--- Percona-Server/mysql-test/suite/innodb/r/percona_innodb_doublewrite_file.result 1970-01-01 00:00:00 +0000
3+++ Percona-Server/mysql-test/suite/innodb/r/percona_innodb_doublewrite_file.result 2012-11-13 06:02:21 +0000
4@@ -0,0 +1,13 @@
5+show variables like 'innodb_doublewrite_file%';
6+Variable_name Value
7+innodb_doublewrite_file ib_doublewrite
8+create table t1 (a int primary key auto_increment, b varchar(100)) engine=innodb;
9+insert into t1 (b) values ("hello");
10+insert into t1 (b) values ("cruel");
11+insert into t1 (b) values ("world");
12+select * from t1 order by a;
13+a b
14+1 hello
15+2 cruel
16+3 world
17+drop table t1;
18
19=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file-master.opt'
20--- Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file-master.opt 1970-01-01 00:00:00 +0000
21+++ Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file-master.opt 2012-11-13 06:02:21 +0000
22@@ -0,0 +1,1 @@
23+--innodb_doublewrite_file=ib_doublewrite
24
25=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file.test'
26--- Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file.test 1970-01-01 00:00:00 +0000
27+++ Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file.test 2012-11-13 06:02:21 +0000
28@@ -0,0 +1,12 @@
29+--source include/have_innodb.inc
30+show variables like 'innodb_doublewrite_file%';
31+
32+create table t1 (a int primary key auto_increment, b varchar(100)) engine=innodb;
33+
34+insert into t1 (b) values ("hello");
35+insert into t1 (b) values ("cruel");
36+insert into t1 (b) values ("world");
37+
38+select * from t1 order by a;
39+
40+drop table t1;
41
42=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result'
43--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result 1970-01-01 00:00:00 +0000
44+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result 2012-11-13 06:02:21 +0000
45@@ -0,0 +1,3 @@
46+show variables like 'innodb_doublewrite_file%';
47+Variable_name Value
48+innodb_doublewrite_file ib_doublewrite
49
50=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic-master.opt'
51--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic-master.opt 1970-01-01 00:00:00 +0000
52+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic-master.opt 2012-11-13 06:02:21 +0000
53@@ -0,0 +1,1 @@
54+--innodb_doublewrite_file=ib_doublewrite
55
56=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test'
57--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test 1970-01-01 00:00:00 +0000
58+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test 2012-11-13 06:02:21 +0000
59@@ -0,0 +1,2 @@
60+--source include/have_innodb.inc
61+show variables like 'innodb_doublewrite_file%';
62
63=== modified file 'Percona-Server/storage/innobase/buf/buf0buf.cc'
64--- Percona-Server/storage/innobase/buf/buf0buf.cc 2012-10-16 06:21:51 +0000
65+++ Percona-Server/storage/innobase/buf/buf0buf.cc 2012-11-13 06:02:21 +0000
66@@ -3951,7 +3951,8 @@
67 read_space_id = mach_read_from_4(
68 frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
69
70- if (bpage->space == TRX_SYS_SPACE
71+ if ((bpage->space == TRX_SYS_SPACE
72+ || (srv_doublewrite_file && bpage->space == TRX_DOUBLEWRITE_SPACE))
73 && buf_dblwr_page_inside(bpage->offset)) {
74
75 ut_print_timestamp(stderr);
76
77=== modified file 'Percona-Server/storage/innobase/buf/buf0dblwr.cc'
78--- Percona-Server/storage/innobase/buf/buf0dblwr.cc 2012-08-22 01:40:20 +0000
79+++ Percona-Server/storage/innobase/buf/buf0dblwr.cc 2012-11-13 06:02:21 +0000
80@@ -93,11 +93,12 @@
81 byte*
82 buf_dblwr_get(
83 /*==========*/
84+ ulint space_id,
85 mtr_t* mtr) /*!< in/out: MTR to hold the page latch */
86 {
87 buf_block_t* block;
88
89- block = buf_page_get(TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO,
90+ block = buf_page_get(space_id, 0, TRX_SYS_PAGE_NO,
91 RW_X_LATCH, mtr);
92 buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
93
94@@ -157,9 +158,9 @@
95 /****************************************************************//**
96 Creates the doublewrite buffer to a new InnoDB installation. The header of the
97 doublewrite buffer is placed on the trx system header page. */
98-UNIV_INTERN
99+static
100 void
101-buf_dblwr_create(void)
102+buf_dblwr_create_low(ulint space_id)
103 /*==================*/
104 {
105 buf_block_t* block2;
106@@ -171,24 +172,20 @@
107 ulint i;
108 mtr_t mtr;
109
110- if (buf_dblwr) {
111- /* Already inited */
112-
113- return;
114- }
115-
116 start_again:
117 mtr_start(&mtr);
118 buf_dblwr_being_created = TRUE;
119
120- doublewrite = buf_dblwr_get(&mtr);
121+ doublewrite = buf_dblwr_get(space_id, &mtr);
122
123 if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC)
124 == TRX_SYS_DOUBLEWRITE_MAGIC_N) {
125 /* The doublewrite buffer has already been created:
126 just read in some numbers */
127
128- buf_dblwr_init(doublewrite);
129+ if (space_id == TRX_SYS_SPACE) {
130+ buf_dblwr_init(doublewrite);
131+ }
132
133 mtr_commit(&mtr);
134 buf_dblwr_being_created = FALSE;
135@@ -197,8 +194,8 @@
136
137 ut_print_timestamp(stderr);
138 fprintf(stderr,
139- " InnoDB: Doublewrite buffer not found:"
140- " creating new\n");
141+ " InnoDB: Doublewrite buffer not found in tablespace (id %lu):"
142+ " creating new\n", space_id);
143
144 if (buf_pool_get_curr_size()
145 < ((2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE
146@@ -213,7 +210,7 @@
147 exit(1);
148 }
149
150- block2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,
151+ block2 = fseg_create(space_id, TRX_SYS_PAGE_NO,
152 TRX_SYS_DOUBLEWRITE
153 + TRX_SYS_DOUBLEWRITE_FSEG, &mtr);
154
155@@ -303,7 +300,7 @@
156 are active, restart the MTR occasionally. */
157 mtr_commit(&mtr);
158 mtr_start(&mtr);
159- doublewrite = buf_dblwr_get(&mtr);
160+ doublewrite = buf_dblwr_get(space_id, &mtr);
161 fseg_header = doublewrite
162 + TRX_SYS_DOUBLEWRITE_FSEG;
163 }
164@@ -332,12 +329,32 @@
165 buf_pool_invalidate();
166
167 ut_print_timestamp(stderr);
168- fprintf(stderr, " InnoDB: Doublewrite buffer created\n");
169+ fprintf(stderr, " InnoDB: Doublewrite buffer created in tablespace id %lu\n", space_id);
170
171 goto start_again;
172 }
173
174 /****************************************************************//**
175+Creates the doublewrite buffer to a new InnoDB installation. The header of the
176+doublewrite buffer is placed on the trx system header page. */
177+UNIV_INTERN
178+void
179+buf_dblwr_create(void)
180+{
181+ if (buf_dblwr) {
182+ /* Already inited */
183+
184+ return;
185+ }
186+
187+ buf_dblwr_create_low(TRX_SYS_SPACE);
188+
189+ if (srv_doublewrite_file) {
190+ buf_dblwr_create_low(TRX_DOUBLEWRITE_SPACE);
191+ }
192+}
193+
194+/****************************************************************//**
195 At a database startup initializes the doublewrite buffer memory structure if
196 we already have a doublewrite buffer created in the data files. If we are
197 upgrading to an InnoDB version which supports multiple tablespaces, then this
198@@ -358,10 +375,20 @@
199 byte* page;
200 ibool reset_space_ids = FALSE;
201 byte* doublewrite;
202+ ulint doublewrite_space_id;
203 ulint space_id;
204 ulint page_no;
205 ulint i;
206
207+ if (srv_doublewrite_file) {
208+ doublewrite_space_id = TRX_DOUBLEWRITE_SPACE;
209+ fprintf(stderr,
210+ "InnoDB: doublewrite file '%s' is used.\n",
211+ srv_doublewrite_file);
212+ } else {
213+ doublewrite_space_id = TRX_SYS_SPACE;
214+ }
215+
216 /* We do the file i/o past the buffer pool */
217
218 unaligned_read_buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE));
219@@ -372,7 +399,7 @@
220 /* Read the trx sys header to check if we are using the doublewrite
221 buffer */
222
223- fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, 0,
224+ fil_io(OS_FILE_READ, TRUE, doublewrite_space_id, 0, TRX_SYS_PAGE_NO, 0,
225 UNIV_PAGE_SIZE, read_buf, NULL);
226 doublewrite = read_buf + TRX_SYS_DOUBLEWRITE;
227
228@@ -408,10 +435,10 @@
229
230 /* Read the pages from the doublewrite buffer to memory */
231
232- fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, block1, 0,
233+ fil_io(OS_FILE_READ, TRUE, doublewrite_space_id, 0, block1, 0,
234 TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
235 buf, NULL);
236- fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, block2, 0,
237+ fil_io(OS_FILE_READ, TRUE, doublewrite_space_id, 0, block2, 0,
238 TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
239 buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
240 NULL);
241@@ -467,7 +494,8 @@
242 " doublewrite buf.\n",
243 (ulong) space_id, (ulong) page_no, (ulong) i);
244
245- } else if (space_id == TRX_SYS_SPACE
246+ } else if ((space_id == TRX_SYS_SPACE
247+ || (srv_doublewrite_file && space_id == TRX_DOUBLEWRITE_SPACE))
248 && ((page_no >= block1
249 && page_no
250 < block1 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE)
251@@ -751,6 +779,13 @@
252 ulint len;
253 ulint len2;
254 ulint i;
255+ ulint doublewrite_space_id;
256+
257+ if (srv_doublewrite_file) {
258+ doublewrite_space_id = TRX_DOUBLEWRITE_SPACE;
259+ } else {
260+ doublewrite_space_id = TRX_SYS_SPACE;
261+ }
262
263 if (!srv_use_doublewrite_buf || buf_dblwr == NULL) {
264 /* Sync the writes to the disk. */
265@@ -823,7 +858,7 @@
266 len = ut_min(TRX_SYS_DOUBLEWRITE_BLOCK_SIZE,
267 buf_dblwr->first_free) * UNIV_PAGE_SIZE;
268
269- fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
270+ fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0,
271 buf_dblwr->block1, 0, len,
272 (void*) write_buf, NULL);
273
274@@ -839,7 +874,7 @@
275 write_buf = buf_dblwr->write_buf
276 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE;
277
278- fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
279+ fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0,
280 buf_dblwr->block2, 0, len,
281 (void*) write_buf, NULL);
282
283@@ -849,7 +884,7 @@
284 srv_stats.dblwr_writes.inc();
285
286 /* Now flush the doublewrite buffer data to disk */
287- fil_flush(TRX_SYS_SPACE);
288+ fil_flush(doublewrite_space_id);
289
290 /* We know that the writes have been flushed to disk now
291 and in recovery we will find them in the doublewrite buffer
292@@ -967,6 +1002,13 @@
293 ulint zip_size;
294 ulint offset;
295 ulint i;
296+ ulint doublewrite_space_id;
297+
298+ if (srv_doublewrite_file) {
299+ doublewrite_space_id = TRX_DOUBLEWRITE_SPACE;
300+ } else {
301+ doublewrite_space_id = TRX_SYS_SPACE;
302+ }
303
304 ut_a(buf_page_in_file(bpage));
305 ut_a(srv_use_doublewrite_buf);
306@@ -1046,21 +1088,21 @@
307 memset(buf_dblwr->write_buf + UNIV_PAGE_SIZE * i
308 + zip_size, 0, UNIV_PAGE_SIZE - zip_size);
309
310- fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
311+ fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0,
312 offset, 0, UNIV_PAGE_SIZE,
313 (void*) (buf_dblwr->write_buf
314 + UNIV_PAGE_SIZE * i), NULL);
315 } else {
316 /* It is a regular page. Write it directly to the
317 doublewrite buffer */
318- fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,
319+ fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0,
320 offset, 0, UNIV_PAGE_SIZE,
321 (void*) ((buf_block_t*) bpage)->frame,
322 NULL);
323 }
324
325 /* Now flush the doublewrite buffer data to disk */
326- fil_flush(TRX_SYS_SPACE);
327+ fil_flush(doublewrite_space_id);
328
329 /* We know that the write has been flushed to disk now
330 and during recovery we will find it in the doublewrite buffer
331
332=== modified file 'Percona-Server/storage/innobase/buf/buf0rea.cc'
333--- Percona-Server/storage/innobase/buf/buf0rea.cc 2012-10-16 06:21:51 +0000
334+++ Percona-Server/storage/innobase/buf/buf0rea.cc 2012-11-13 06:02:21 +0000
335@@ -133,7 +133,9 @@
336 ignore_nonexistent_pages = mode & BUF_READ_IGNORE_NONEXISTENT_PAGES;
337 mode &= ~BUF_READ_IGNORE_NONEXISTENT_PAGES;
338
339- if (space == TRX_SYS_SPACE && buf_dblwr_page_inside(offset)) {
340+ if ((space == TRX_SYS_SPACE
341+ || (srv_doublewrite_file && space == TRX_DOUBLEWRITE_SPACE))
342+ && buf_dblwr_page_inside(offset)) {
343 ut_print_timestamp(stderr);
344 fprintf(stderr,
345 " InnoDB: Warning: trying to read"
346
347=== modified file 'Percona-Server/storage/innobase/dict/dict0load.cc'
348--- Percona-Server/storage/innobase/dict/dict0load.cc 2012-10-16 06:21:51 +0000
349+++ Percona-Server/storage/innobase/dict/dict0load.cc 2012-11-13 06:02:21 +0000
350@@ -45,6 +45,7 @@
351 #include "dict0priv.h"
352 #include "ha_prototypes.h" /* innobase_casedn_str() */
353 #include "fts0priv.h"
354+#include "trx0sys.h"
355
356 /** Following are the InnoDB system tables. The positions in
357 this array are referenced by enum dict_system_table_id. */
358@@ -1066,7 +1067,7 @@
359 discarded = !!(flags2 & DICT_TF2_DISCARDED);
360 }
361
362- if (space_id == 0) {
363+ if (trx_sys_sys_space(space_id)) {
364 /* The system tablespace always exists. */
365 ut_ad(!discarded);
366 } else if (in_crash_recovery) {
367@@ -2248,7 +2249,7 @@
368 btr_pcur_close(&pcur);
369 mtr_commit(&mtr);
370
371- if (table->space == 0) {
372+ if (trx_sys_sys_space(table->space)) {
373 /* The system tablespace is always available. */
374 } else if (table->flags2 & DICT_TF2_DISCARDED) {
375
376
377=== modified file 'Percona-Server/storage/innobase/fil/fil0fil.cc'
378--- Percona-Server/storage/innobase/fil/fil0fil.cc 2012-10-16 06:21:51 +0000
379+++ Percona-Server/storage/innobase/fil/fil0fil.cc 2012-11-13 06:02:21 +0000
380@@ -308,7 +308,7 @@
381 static fil_system_t* fil_system = NULL;
382
383 /** Determine if (i) is a user tablespace id or not. */
384-# define fil_is_user_tablespace_id(i) ((i) > srv_undo_tablespaces_open)
385+# define fil_is_user_tablespace_id(i) ((i) > srv_undo_tablespaces_open && !trx_sys_sys_space(i))
386
387 /** Determine if user has explicitly disabled fsync(). */
388 #ifndef __WIN__
389@@ -668,7 +668,7 @@
390
391 UT_LIST_ADD_LAST(chain, space->chain, node);
392
393- if (id < SRV_LOG_SPACE_FIRST_ID && fil_system->max_assigned_id < id) {
394+ if (id < SRV_EXTRA_SYS_SPACE_FIRST_ID && fil_system->max_assigned_id < id) {
395
396 fil_system->max_assigned_id = id;
397 }
398@@ -729,14 +729,14 @@
399 size_bytes = os_file_get_size(node->handle);
400 ut_a(size_bytes != (os_offset_t) -1);
401 #ifdef UNIV_HOTBACKUP
402- if (space->id == 0) {
403+ if (trx_sys_sys_space(space->id)) {
404 node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
405 os_file_close(node->handle);
406 goto add_size;
407 }
408 #endif /* UNIV_HOTBACKUP */
409 ut_a(space->purpose != FIL_LOG);
410- ut_a(fil_is_user_tablespace_id(space->id));
411+ ut_a(!trx_sys_sys_space(space->id));
412
413 if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
414 fprintf(stderr,
415@@ -781,7 +781,7 @@
416 }
417
418 if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED
419- || space_id == 0)) {
420+ || trx_sys_sys_space(space_id))) {
421 fprintf(stderr,
422 "InnoDB: Error: tablespace id %lu"
423 " in file %s is not sensible\n",
424@@ -864,7 +864,6 @@
425 fil_n_file_opened++;
426
427 if (fil_space_belongs_in_lru(space)) {
428-
429 /* Put the node to the LRU list */
430 UT_LIST_ADD_FIRST(LRU, system->LRU, node);
431 }
432@@ -903,7 +902,6 @@
433 fil_n_file_opened--;
434
435 if (fil_space_belongs_in_lru(node->space)) {
436-
437 ut_a(UT_LIST_GET_LEN(system->LRU) > 0);
438
439 /* The node is in the LRU list, remove it */
440@@ -999,7 +997,7 @@
441 retry:
442 mutex_enter(&fil_system->mutex);
443
444- if (space_id == 0 || space_id >= SRV_LOG_SPACE_FIRST_ID) {
445+ if (trx_sys_sys_space(space_id) || space_id >= SRV_LOG_SPACE_FIRST_ID) {
446 /* We keep log files and system tablespace files always open;
447 this is important in preventing deadlocks in this module, as
448 a page read completion often performs another read from the
449@@ -1276,9 +1274,9 @@
450 space->tablespace_version = fil_system->tablespace_version;
451 space->mark = FALSE;
452
453- if (purpose == FIL_TABLESPACE && !recv_recovery_on
454- && id > fil_system->max_assigned_id) {
455-
456+ if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on)
457+ && UNIV_UNLIKELY(id < SRV_EXTRA_SYS_SPACE_FIRST_ID)
458+ && UNIV_UNLIKELY(id > fil_system->max_assigned_id)) {
459 if (!fil_system->space_id_reuse_warned) {
460 fil_system->space_id_reuse_warned = TRUE;
461
462@@ -1350,7 +1348,7 @@
463 (ulong) SRV_LOG_SPACE_FIRST_ID);
464 }
465
466- success = (id < SRV_LOG_SPACE_FIRST_ID);
467+ success = (id < SRV_EXTRA_SYS_SPACE_FIRST_ID);
468
469 if (success) {
470 *space_id = fil_system->max_assigned_id = id;
471@@ -1773,6 +1771,10 @@
472 ut_error;
473 }
474
475+ if (max_id >= SRV_EXTRA_SYS_SPACE_FIRST_ID) {
476+ return;
477+ }
478+
479 mutex_enter(&fil_system->mutex);
480
481 if (fil_system->max_assigned_id < max_id) {
482@@ -4067,7 +4069,7 @@
483 }
484
485 #ifdef UNIV_HOTBACKUP
486- if (fsp->id == ULINT_UNDEFINED || fsp->id == 0) {
487+ if (fsp->id == ULINT_UNDEFINED || trx_sys_sys_space(fsp->id)) {
488 char* new_path;
489
490 fprintf(stderr,
491@@ -4967,7 +4969,6 @@
492 }
493
494 if (node->n_pending == 0 && fil_space_belongs_in_lru(node->space)) {
495-
496 /* The node must be put back to the LRU list */
497 UT_LIST_ADD_FIRST(LRU, system->LRU, node);
498 }
499
500=== modified file 'Percona-Server/storage/innobase/fsp/fsp0fsp.cc'
501--- Percona-Server/storage/innobase/fsp/fsp0fsp.cc 2012-08-22 01:40:20 +0000
502+++ Percona-Server/storage/innobase/fsp/fsp0fsp.cc 2012-11-13 06:02:21 +0000
503@@ -49,7 +49,7 @@
504 #endif /* UNIV_HOTBACKUP */
505 #include "dict0mem.h"
506 #include "srv0start.h"
507-
508+#include "trx0sys.h"
509
510 #ifndef UNIV_HOTBACKUP
511 /** Flag to indicate if we have printed the tablespace full error. */
512@@ -832,10 +832,10 @@
513 flst_init(header + FSP_SEG_INODES_FREE, mtr);
514
515 mlog_write_ull(header + FSP_SEG_ID, 1, mtr);
516- if (space == 0) {
517+ if (space == TRX_SYS_SPACE || space == TRX_DOUBLEWRITE_SPACE) {
518 fsp_fill_free_list(FALSE, space, header, mtr);
519 btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,
520- 0, 0, DICT_IBUF_ID_MIN + space,
521+ space, 0, DICT_IBUF_ID_MIN + space,
522 dict_ind_redundant, mtr);
523 } else {
524 fsp_fill_free_list(TRUE, space, header, mtr);
525
526=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
527--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-10-16 06:21:51 +0000
528+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-11-13 06:02:21 +0000
529@@ -159,6 +159,7 @@
530 static char* innobase_disable_monitor_counter = NULL;
531 static char* innobase_reset_monitor_counter = NULL;
532 static char* innobase_reset_all_monitor_counter = NULL;
533+static char* innobase_doublewrite_file = NULL;
534
535 /* The highest file format being used in the database. The value can be
536 set by user, however, it will be adjusted to the newer file format if
537@@ -2920,6 +2921,8 @@
538 goto error;
539 }
540
541+ srv_doublewrite_file = innobase_doublewrite_file;
542+
543 /* -------------- All log files ---------------------------*/
544
545 /* The default dir for log files is the datadir of MySQL */
546@@ -15799,6 +15802,11 @@
547 1, /* Minimum value */
548 TRX_SYS_N_RSEGS, 0); /* Maximum value */
549
550+static MYSQL_SYSVAR_STR(doublewrite_file, innobase_doublewrite_file,
551+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
552+ "Path to special datafile for doublewrite buffer. (default is "": not used) ### ONLY FOR EXPERTS!!! ###",
553+ NULL, NULL, NULL);
554+
555 static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
556 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
557 "The AUTOINC lock modes supported by InnoDB: "
558@@ -15980,6 +15988,7 @@
559 MYSQL_SYSVAR(concurrency_tickets),
560 MYSQL_SYSVAR(compression_level),
561 MYSQL_SYSVAR(data_file_path),
562+ MYSQL_SYSVAR(doublewrite_file),
563 MYSQL_SYSVAR(data_home_dir),
564 MYSQL_SYSVAR(doublewrite),
565 MYSQL_SYSVAR(api_enable_binlog),
566
567=== modified file 'Percona-Server/storage/innobase/include/mtr0log.ic'
568--- Percona-Server/storage/innobase/include/mtr0log.ic 2012-01-26 11:57:53 +0000
569+++ Percona-Server/storage/innobase/include/mtr0log.ic 2012-11-13 06:02:21 +0000
570@@ -28,8 +28,8 @@
571 #include "buf0buf.h"
572 #include "buf0dblwr.h"
573 #include "fsp0types.h"
574+#include "srv0srv.h"
575 #include "trx0sys.h"
576-
577 /********************************************************//**
578 Opens a buffer to mlog. It must be closed with mlog_close.
579 @return buffer, NULL if log mode MTR_LOG_NONE */
580@@ -202,7 +202,8 @@
581 the doublewrite buffer is located in pages
582 FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the
583 system tablespace */
584- if (space == TRX_SYS_SPACE
585+ if ((space == TRX_SYS_SPACE
586+ || (srv_doublewrite_file && space == TRX_DOUBLEWRITE_SPACE))
587 && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) {
588 if (buf_dblwr_being_created) {
589 /* Do nothing: we only come to this branch in an
590
591=== modified file 'Percona-Server/storage/innobase/include/srv0srv.h'
592--- Percona-Server/storage/innobase/include/srv0srv.h 2012-10-16 06:21:51 +0000
593+++ Percona-Server/storage/innobase/include/srv0srv.h 2012-11-13 06:02:21 +0000
594@@ -235,6 +235,8 @@
595 extern ulint* srv_data_file_sizes;
596 extern ulint* srv_data_file_is_raw_partition;
597
598+extern char* srv_doublewrite_file;
599+
600 extern ibool srv_auto_extend_last_data_file;
601 extern ulint srv_last_file_size_max;
602 extern char** srv_log_group_home_dirs;
603
604=== modified file 'Percona-Server/storage/innobase/include/srv0start.h'
605--- Percona-Server/storage/innobase/include/srv0start.h 2012-08-22 01:40:20 +0000
606+++ Percona-Server/storage/innobase/include/srv0start.h 2012-11-13 06:02:21 +0000
607@@ -173,4 +173,7 @@
608 /** Log 'spaces' have id's >= this */
609 #define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0UL
610
611+/** reserved for extra system tables */
612+#define SRV_EXTRA_SYS_SPACE_FIRST_ID 0xFFFFFFE0UL
613+
614 #endif
615
616=== modified file 'Percona-Server/storage/innobase/include/trx0sys.h'
617--- Percona-Server/storage/innobase/include/trx0sys.h 2012-10-16 06:21:51 +0000
618+++ Percona-Server/storage/innobase/include/trx0sys.h 2012-11-13 06:02:21 +0000
619@@ -78,6 +78,22 @@
620 /*=============*/
621 ulint space, /*!< in: space */
622 ulint page_no);/*!< in: page number */
623+/***************************************************************//**
624+Checks if a space is the system tablespaces.
625+@return TRUE if system tablespace */
626+UNIV_INLINE
627+ibool
628+trx_sys_sys_space(
629+/*==============*/
630+ ulint space); /*!< in: space */
631+/***************************************************************//**
632+Checks if a space is the doublewrite tablespace.
633+@return TRUE if doublewrite tablespace */
634+UNIV_INLINE
635+ibool
636+trx_sys_doublewrite_space(
637+/*======================*/
638+ ulint space); /*!< in: space */
639 /*****************************************************************//**
640 Creates and initializes the central memory structures for the transaction
641 system. This is called when the database is started.
642@@ -463,6 +479,8 @@
643
644 /* Space id and page no where the trx system file copy resides */
645 #define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
646+#define TRX_DOUBLEWRITE_SPACE 0xFFFFFFE0UL /* the doublewrite buffer tablespace if used */
647+#define TRX_SYS_SPACE_MAX 9 /* reserved max space id for system tablespaces */
648 #include "fsp0fsp.h"
649 #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
650
651@@ -660,3 +678,9 @@
652 #endif
653
654 #endif
655+
656+UNIV_INTERN
657+void
658+trx_sys_dummy_create(
659+/*=================*/
660+ ulint space);
661
662=== modified file 'Percona-Server/storage/innobase/include/trx0sys.ic'
663--- Percona-Server/storage/innobase/include/trx0sys.ic 2011-11-21 00:04:40 +0000
664+++ Percona-Server/storage/innobase/include/trx0sys.ic 2012-11-13 06:02:21 +0000
665@@ -25,6 +25,7 @@
666
667 #include "trx0trx.h"
668 #include "data0type.h"
669+#include "srv0srv.h"
670 #ifndef UNIV_HOTBACKUP
671 # include "srv0srv.h"
672 # include "mtr0log.h"
673@@ -71,6 +72,40 @@
674 }
675
676 /***************************************************************//**
677+Checks if a space is the system tablespaces.
678+@return TRUE if system tablespace */
679+UNIV_INLINE
680+ibool
681+trx_sys_sys_space(
682+/*==============*/
683+ ulint space) /*!< in: space */
684+{
685+ if (srv_doublewrite_file) {
686+ /* several spaces are reserved */
687+ return((ibool)(space == TRX_SYS_SPACE || space == TRX_DOUBLEWRITE_SPACE));
688+ } else {
689+ return((ibool)(space == TRX_SYS_SPACE));
690+ }
691+}
692+
693+/***************************************************************//**
694+Checks if a space is the doublewrite tablespace.
695+@return TRUE if doublewrite tablespace */
696+UNIV_INLINE
697+ibool
698+trx_sys_doublewrite_space(
699+/*======================*/
700+ ulint space) /*!< in: space */
701+{
702+ if (srv_doublewrite_file) {
703+ /* doublewrite buffer is separated */
704+ return((ibool)(space == TRX_DOUBLEWRITE_SPACE));
705+ } else {
706+ return((ibool)(space == TRX_SYS_SPACE));
707+ }
708+}
709+
710+/***************************************************************//**
711 Gets the pointer in the nth slot of the rseg array.
712 @return pointer to rseg object, NULL if slot not in use */
713 UNIV_INLINE
714
715=== modified file 'Percona-Server/storage/innobase/row/row0mysql.cc'
716--- Percona-Server/storage/innobase/row/row0mysql.cc 2012-10-16 06:21:51 +0000
717+++ Percona-Server/storage/innobase/row/row0mysql.cc 2012-11-13 06:02:21 +0000
718@@ -4108,7 +4108,7 @@
719 a temp table or if the tablesace has been discarded. */
720 print_msg = !(is_temp || ibd_file_missing);
721
722- if (err == DB_SUCCESS && space_id > TRX_SYS_SPACE) {
723+ if (err == DB_SUCCESS && !trx_sys_sys_space(space_id)) {
724 if (!is_temp
725 && !fil_space_for_table_exists_in_mem(
726 space_id, tablename, FALSE, print_msg)) {
727
728=== modified file 'Percona-Server/storage/innobase/srv/srv0srv.cc'
729--- Percona-Server/storage/innobase/srv/srv0srv.cc 2012-10-16 06:21:51 +0000
730+++ Percona-Server/storage/innobase/srv/srv0srv.cc 2012-11-13 06:02:21 +0000
731@@ -161,6 +161,8 @@
732 /* size in database pages */
733 UNIV_INTERN ulint* srv_data_file_sizes = NULL;
734
735+UNIV_INTERN char* srv_doublewrite_file = NULL;
736+
737 /* if TRUE, then we auto-extend the last data file */
738 UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE;
739 /* if != 0, this tells the max size auto-extending may increase the
740
741=== modified file 'Percona-Server/storage/innobase/srv/srv0start.cc'
742--- Percona-Server/storage/innobase/srv/srv0start.cc 2012-10-16 06:21:51 +0000
743+++ Percona-Server/storage/innobase/srv/srv0start.cc 2012-11-13 06:02:21 +0000
744@@ -761,6 +761,7 @@
745 /*======================*/
746 ibool* create_new_db, /*!< out: TRUE if new database should be
747 created */
748+ ibool* create_new_doublewrite_file,
749 #ifdef UNIV_LOG_ARCHIVE
750 ulint* min_arch_log_no,/*!< out: min of archived log
751 numbers in data files */
752@@ -796,6 +797,7 @@
753 *sum_of_new_sizes = 0;
754
755 *create_new_db = FALSE;
756+ *create_new_doublewrite_file = FALSE;
757
758 srv_normalize_path_for_win(srv_data_home);
759
760@@ -1066,6 +1068,139 @@
761 srv_data_file_is_raw_partition[i] != 0);
762 }
763
764+ /* special file for doublewrite buffer */
765+ if (srv_doublewrite_file)
766+ {
767+ srv_normalize_path_for_win(srv_doublewrite_file);
768+
769+ fprintf(stderr,
770+ "InnoDB: Note: The innodb_doublewrite_file option has been specified.\n"
771+ "InnoDB: This option is for experts only. Don't use it unless you understand WELL what it is.\n"
772+ "InnoDB: ### Don't specify a file older than the last checkpoint. ###\n"
773+ "InnoDB: Otherwise, the older doublewrite buffer will break your data during recovery!\n");
774+
775+ strcpy(name, srv_doublewrite_file);
776+
777+ /* First we try to create the file: if it already
778+ exists, ret will get value FALSE */
779+
780+ files[i] = os_file_create(innodb_file_data_key, name, OS_FILE_CREATE,
781+ OS_FILE_NORMAL,
782+ OS_DATA_FILE, &ret);
783+
784+ if (ret == FALSE && os_file_get_last_error(FALSE)
785+ != OS_FILE_ALREADY_EXISTS
786+#ifdef UNIV_AIX
787+ /* AIX 5.1 after security patch ML7 may have
788+ errno set to 0 here, which causes our function
789+ to return 100; work around that AIX problem */
790+ && os_file_get_last_error(FALSE) != 100
791+#endif
792+ ) {
793+ fprintf(stderr,
794+ "InnoDB: Error in creating"
795+ " or opening %s\n",
796+ name);
797+
798+ return(DB_ERROR);
799+ }
800+
801+ if (ret == FALSE) {
802+ /* We open the data file */
803+
804+ files[i] = os_file_create(innodb_file_data_key,
805+ name, OS_FILE_OPEN, OS_FILE_NORMAL,
806+ OS_DATA_FILE, &ret);
807+
808+ if (!ret) {
809+ fprintf(stderr,
810+ "InnoDB: Error in opening %s\n", name);
811+ os_file_get_last_error(TRUE);
812+
813+ return(DB_ERROR);
814+ }
815+
816+ size = os_file_get_size(files[i]);
817+ /* Round size downward to megabytes */
818+
819+ rounded_size_pages = (ulint)
820+ (size >> UNIV_PAGE_SIZE_SHIFT);
821+
822+ if (rounded_size_pages != TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9) {
823+
824+ fprintf(stderr,
825+ "InnoDB: Warning: doublewrite buffer file %s"
826+ " is of a different size\n"
827+ "InnoDB: %lu pages"
828+ " (rounded down to MB)\n"
829+ "InnoDB: than intended size"
830+ " %lu pages...\n",
831+ name,
832+ (ulong) rounded_size_pages,
833+ (ulong) TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9);
834+ }
835+
836+ fil_read_first_page(files[i], one_opened, &flags,
837+ &space,
838+#ifdef UNIV_LOG_ARCHIVE
839+ min_arch_log_no, max_arch_log_no,
840+#endif /* UNIV_LOG_ARCHIVE */
841+ min_flushed_lsn, max_flushed_lsn);
842+ one_opened = TRUE;
843+ } else {
844+ /* We created the data file and now write it full of
845+ zeros */
846+
847+ *create_new_doublewrite_file = TRUE;
848+
849+ ut_print_timestamp(stderr);
850+ fprintf(stderr,
851+ " InnoDB: Doublewrite buffer file %s did not"
852+ " exist. It will be be created.\n",
853+ name);
854+
855+ if (*create_new_db == FALSE) {
856+ fprintf(stderr,
857+ "InnoDB: Notice: Previous version's ibdata files may cause crash.\n"
858+ " If you use that, please use the ibdata files of this version.\n");
859+ }
860+
861+ ut_print_timestamp(stderr);
862+ fprintf(stderr,
863+ " InnoDB: Setting file %s size to %lu MB\n",
864+ name,
865+ (ulong) ((TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9)
866+ >> (20 - UNIV_PAGE_SIZE_SHIFT)));
867+
868+ fprintf(stderr,
869+ "InnoDB: Database physically writes the"
870+ " file full: wait...\n");
871+
872+ ret = os_file_set_size(
873+ name, files[i],
874+ (TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9) << UNIV_PAGE_SIZE_SHIFT);
875+
876+ if (!ret) {
877+ fprintf(stderr,
878+ "InnoDB: Error in creating %s:"
879+ " probably out of disk space\n", name);
880+
881+ return(DB_ERROR);
882+ }
883+ }
884+
885+ ret = os_file_close(files[i]);
886+ ut_a(ret);
887+
888+ fil_space_create(name, TRX_DOUBLEWRITE_SPACE, 0, FIL_TABLESPACE);
889+
890+ ut_a(fil_validate());
891+
892+ fil_node_create(name, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, TRX_DOUBLEWRITE_SPACE, FALSE);
893+
894+ i++;
895+ }
896+
897 return(DB_SUCCESS);
898 }
899
900@@ -1448,6 +1583,7 @@
901 /*====================================*/
902 {
903 ibool create_new_db;
904+ ibool create_new_doublewrite_file;
905 ibool log_file_created;
906 ibool log_created = FALSE;
907 ibool log_opened = FALSE;
908@@ -1940,6 +2076,7 @@
909 }
910
911 err = open_or_create_data_files(&create_new_db,
912+ &create_new_doublewrite_file,
913 #ifdef UNIV_LOG_ARCHIVE
914 &min_arch_log_no, &max_arch_log_no,
915 #endif /* UNIV_LOG_ARCHIVE */
916@@ -2112,6 +2249,14 @@
917
918 trx_purge_sys_create(srv_n_purge_threads, ib_bh);
919
920+ if (create_new_doublewrite_file) {
921+ mtr_start(&mtr);
922+ fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr);
923+ mtr_commit(&mtr);
924+
925+ trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE);
926+ }
927+
928 dict_create();
929
930 srv_startup_is_before_trx_rollback_phase = FALSE;
931@@ -2146,6 +2291,13 @@
932 recv_recovery_from_archive_finish();
933 #endif /* UNIV_LOG_ARCHIVE */
934 } else {
935+ char* save_srv_doublewrite_file = NULL;
936+
937+ if (create_new_doublewrite_file) {
938+ /* doublewrite_file cannot be used for recovery yet. */
939+ save_srv_doublewrite_file = srv_doublewrite_file;
940+ srv_doublewrite_file = NULL;
941+ }
942
943 /* Check if we support the max format that is stamped
944 on the system tablespace.
945@@ -2235,6 +2387,17 @@
946 we have finished the recovery process so that the
947 image of TRX_SYS_PAGE_NO is not stale. */
948 trx_sys_file_format_tag_init();
949+
950+ if (create_new_doublewrite_file) {
951+ /* restore the value */
952+ srv_doublewrite_file = save_srv_doublewrite_file;
953+
954+ mtr_start(&mtr);
955+ fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr);
956+ mtr_commit(&mtr);
957+
958+ trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE);
959+ }
960 }
961
962 if (!create_new_db && sum_of_new_sizes > 0) {
963
964=== modified file 'Percona-Server/storage/innobase/trx/trx0sys.cc'
965--- Percona-Server/storage/innobase/trx/trx0sys.cc 2012-10-16 06:21:51 +0000
966+++ Percona-Server/storage/innobase/trx/trx0sys.cc 2012-11-13 06:02:21 +0000
967@@ -385,7 +385,8 @@
968 void
969 trx_sysf_create(
970 /*============*/
971- mtr_t* mtr) /*!< in: mtr */
972+ mtr_t* mtr, /*!< in: mtr */
973+ ulint space_id)
974 {
975 trx_sysf_t* sys_header;
976 ulint slot_no;
977@@ -401,10 +402,10 @@
978 then enter the kernel: we must do it in this order to conform
979 to the latching order rules. */
980
981- mtr_x_lock(fil_space_get_latch(TRX_SYS_SPACE, NULL), mtr);
982+ mtr_x_lock(fil_space_get_latch(space_id, NULL), mtr);
983
984 /* Create the trx sys file block in a new allocated file segment */
985- block = fseg_create(TRX_SYS_SPACE, 0, TRX_SYS + TRX_SYS_FSEG_HEADER,
986+ block = fseg_create(space_id, 0, TRX_SYS + TRX_SYS_FSEG_HEADER,
987 mtr);
988 buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER);
989
990@@ -422,6 +423,12 @@
991 mlog_write_ulint(page + TRX_SYS_DOUBLEWRITE
992 + TRX_SYS_DOUBLEWRITE_MAGIC, 0, MLOG_4BYTES, mtr);
993
994+ if (space_id != TRX_SYS_SPACE) {
995+ /* That is all we need for doublewrite buffer file. */
996+ ut_a(space_id == TRX_DOUBLEWRITE_SPACE);
997+ return;
998+ }
999+
1000 sys_header = trx_sysf_get(mtr);
1001
1002 /* Start counting transaction ids from number 1 up */
1003@@ -445,7 +452,7 @@
1004
1005 /* Create the first rollback segment in the SYSTEM tablespace */
1006 slot_no = trx_sysf_rseg_find_free(mtr);
1007- page_no = trx_rseg_header_create(TRX_SYS_SPACE, 0, ULINT_MAX, slot_no,
1008+ page_no = trx_rseg_header_create(space_id, 0, ULINT_MAX, slot_no,
1009 mtr);
1010
1011 ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID);
1012@@ -599,7 +606,7 @@
1013
1014 mtr_start(&mtr);
1015
1016- trx_sysf_create(&mtr);
1017+ trx_sysf_create(&mtr, TRX_SYS_SPACE);
1018
1019 mtr_commit(&mtr);
1020 }
1021@@ -863,6 +870,26 @@
1022 /* Does nothing at the moment */
1023 }
1024
1025+/*****************************************************************//**
1026+Creates and initializes the dummy transaction system page for tablespace. */
1027+UNIV_INTERN
1028+void
1029+trx_sys_dummy_create(
1030+/*=================*/
1031+ ulint space)
1032+{
1033+ mtr_t mtr;
1034+
1035+ /* This function is only for doublewrite file for now */
1036+ ut_a(space == TRX_DOUBLEWRITE_SPACE);
1037+
1038+ mtr_start(&mtr);
1039+
1040+ trx_sysf_create(&mtr, space);
1041+
1042+ mtr_commit(&mtr);
1043+}
1044+
1045 /*********************************************************************
1046 Creates the rollback segments.
1047 @return number of rollback segments that are active. */

Subscribers

People subscribed via source and target branches