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
=== added file 'Percona-Server/mysql-test/suite/innodb/r/percona_innodb_doublewrite_file.result'
--- Percona-Server/mysql-test/suite/innodb/r/percona_innodb_doublewrite_file.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/r/percona_innodb_doublewrite_file.result 2012-11-13 06:02:21 +0000
@@ -0,0 +1,13 @@
1show variables like 'innodb_doublewrite_file%';
2Variable_name Value
3innodb_doublewrite_file ib_doublewrite
4create table t1 (a int primary key auto_increment, b varchar(100)) engine=innodb;
5insert into t1 (b) values ("hello");
6insert into t1 (b) values ("cruel");
7insert into t1 (b) values ("world");
8select * from t1 order by a;
9a b
101 hello
112 cruel
123 world
13drop table t1;
014
=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file-master.opt'
--- Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file-master.opt 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file-master.opt 2012-11-13 06:02:21 +0000
@@ -0,0 +1,1 @@
1--innodb_doublewrite_file=ib_doublewrite
02
=== added file 'Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file.test'
--- Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/innodb/t/percona_innodb_doublewrite_file.test 2012-11-13 06:02:21 +0000
@@ -0,0 +1,12 @@
1--source include/have_innodb.inc
2show variables like 'innodb_doublewrite_file%';
3
4create table t1 (a int primary key auto_increment, b varchar(100)) engine=innodb;
5
6insert into t1 (b) values ("hello");
7insert into t1 (b) values ("cruel");
8insert into t1 (b) values ("world");
9
10select * from t1 order by a;
11
12drop table t1;
013
=== added file 'Percona-Server/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result'
--- Percona-Server/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/r/innodb_doublewrite_file_basic.result 2012-11-13 06:02:21 +0000
@@ -0,0 +1,3 @@
1show variables like 'innodb_doublewrite_file%';
2Variable_name Value
3innodb_doublewrite_file ib_doublewrite
04
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic-master.opt'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic-master.opt 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic-master.opt 2012-11-13 06:02:21 +0000
@@ -0,0 +1,1 @@
1--innodb_doublewrite_file=ib_doublewrite
02
=== added file 'Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test'
--- Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test 1970-01-01 00:00:00 +0000
+++ Percona-Server/mysql-test/suite/sys_vars/t/innodb_doublewrite_file_basic.test 2012-11-13 06:02:21 +0000
@@ -0,0 +1,2 @@
1--source include/have_innodb.inc
2show variables like 'innodb_doublewrite_file%';
03
=== modified file 'Percona-Server/storage/innobase/buf/buf0buf.cc'
--- Percona-Server/storage/innobase/buf/buf0buf.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/buf/buf0buf.cc 2012-11-13 06:02:21 +0000
@@ -3951,7 +3951,8 @@
3951 read_space_id = mach_read_from_4(3951 read_space_id = mach_read_from_4(
3952 frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);3952 frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
39533953
3954 if (bpage->space == TRX_SYS_SPACE3954 if ((bpage->space == TRX_SYS_SPACE
3955 || (srv_doublewrite_file && bpage->space == TRX_DOUBLEWRITE_SPACE))
3955 && buf_dblwr_page_inside(bpage->offset)) {3956 && buf_dblwr_page_inside(bpage->offset)) {
39563957
3957 ut_print_timestamp(stderr);3958 ut_print_timestamp(stderr);
39583959
=== modified file 'Percona-Server/storage/innobase/buf/buf0dblwr.cc'
--- Percona-Server/storage/innobase/buf/buf0dblwr.cc 2012-08-22 01:40:20 +0000
+++ Percona-Server/storage/innobase/buf/buf0dblwr.cc 2012-11-13 06:02:21 +0000
@@ -93,11 +93,12 @@
93byte*93byte*
94buf_dblwr_get(94buf_dblwr_get(
95/*==========*/95/*==========*/
96 ulint space_id,
96 mtr_t* mtr) /*!< in/out: MTR to hold the page latch */97 mtr_t* mtr) /*!< in/out: MTR to hold the page latch */
97{98{
98 buf_block_t* block;99 buf_block_t* block;
99100
100 block = buf_page_get(TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO,101 block = buf_page_get(space_id, 0, TRX_SYS_PAGE_NO,
101 RW_X_LATCH, mtr);102 RW_X_LATCH, mtr);
102 buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);103 buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK);
103104
@@ -157,9 +158,9 @@
157/****************************************************************//**158/****************************************************************//**
158Creates the doublewrite buffer to a new InnoDB installation. The header of the159Creates the doublewrite buffer to a new InnoDB installation. The header of the
159doublewrite buffer is placed on the trx system header page. */160doublewrite buffer is placed on the trx system header page. */
160UNIV_INTERN161static
161void162void
162buf_dblwr_create(void)163buf_dblwr_create_low(ulint space_id)
163/*==================*/164/*==================*/
164{165{
165 buf_block_t* block2;166 buf_block_t* block2;
@@ -171,24 +172,20 @@
171 ulint i;172 ulint i;
172 mtr_t mtr;173 mtr_t mtr;
173174
174 if (buf_dblwr) {
175 /* Already inited */
176
177 return;
178 }
179
180start_again:175start_again:
181 mtr_start(&mtr);176 mtr_start(&mtr);
182 buf_dblwr_being_created = TRUE;177 buf_dblwr_being_created = TRUE;
183178
184 doublewrite = buf_dblwr_get(&mtr);179 doublewrite = buf_dblwr_get(space_id, &mtr);
185180
186 if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC)181 if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC)
187 == TRX_SYS_DOUBLEWRITE_MAGIC_N) {182 == TRX_SYS_DOUBLEWRITE_MAGIC_N) {
188 /* The doublewrite buffer has already been created:183 /* The doublewrite buffer has already been created:
189 just read in some numbers */184 just read in some numbers */
190185
191 buf_dblwr_init(doublewrite);186 if (space_id == TRX_SYS_SPACE) {
187 buf_dblwr_init(doublewrite);
188 }
192189
193 mtr_commit(&mtr);190 mtr_commit(&mtr);
194 buf_dblwr_being_created = FALSE;191 buf_dblwr_being_created = FALSE;
@@ -197,8 +194,8 @@
197194
198 ut_print_timestamp(stderr);195 ut_print_timestamp(stderr);
199 fprintf(stderr,196 fprintf(stderr,
200 " InnoDB: Doublewrite buffer not found:"197 " InnoDB: Doublewrite buffer not found in tablespace (id %lu):"
201 " creating new\n");198 " creating new\n", space_id);
202199
203 if (buf_pool_get_curr_size()200 if (buf_pool_get_curr_size()
204 < ((2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE201 < ((2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE
@@ -213,7 +210,7 @@
213 exit(1);210 exit(1);
214 }211 }
215212
216 block2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO,213 block2 = fseg_create(space_id, TRX_SYS_PAGE_NO,
217 TRX_SYS_DOUBLEWRITE214 TRX_SYS_DOUBLEWRITE
218 + TRX_SYS_DOUBLEWRITE_FSEG, &mtr);215 + TRX_SYS_DOUBLEWRITE_FSEG, &mtr);
219216
@@ -303,7 +300,7 @@
303 are active, restart the MTR occasionally. */300 are active, restart the MTR occasionally. */
304 mtr_commit(&mtr);301 mtr_commit(&mtr);
305 mtr_start(&mtr);302 mtr_start(&mtr);
306 doublewrite = buf_dblwr_get(&mtr);303 doublewrite = buf_dblwr_get(space_id, &mtr);
307 fseg_header = doublewrite304 fseg_header = doublewrite
308 + TRX_SYS_DOUBLEWRITE_FSEG;305 + TRX_SYS_DOUBLEWRITE_FSEG;
309 }306 }
@@ -332,12 +329,32 @@
332 buf_pool_invalidate();329 buf_pool_invalidate();
333330
334 ut_print_timestamp(stderr);331 ut_print_timestamp(stderr);
335 fprintf(stderr, " InnoDB: Doublewrite buffer created\n");332 fprintf(stderr, " InnoDB: Doublewrite buffer created in tablespace id %lu\n", space_id);
336333
337 goto start_again;334 goto start_again;
338}335}
339336
340/****************************************************************//**337/****************************************************************//**
338Creates the doublewrite buffer to a new InnoDB installation. The header of the
339doublewrite buffer is placed on the trx system header page. */
340UNIV_INTERN
341void
342buf_dblwr_create(void)
343{
344 if (buf_dblwr) {
345 /* Already inited */
346
347 return;
348 }
349
350 buf_dblwr_create_low(TRX_SYS_SPACE);
351
352 if (srv_doublewrite_file) {
353 buf_dblwr_create_low(TRX_DOUBLEWRITE_SPACE);
354 }
355}
356
357/****************************************************************//**
341At a database startup initializes the doublewrite buffer memory structure if358At a database startup initializes the doublewrite buffer memory structure if
342we already have a doublewrite buffer created in the data files. If we are359we already have a doublewrite buffer created in the data files. If we are
343upgrading to an InnoDB version which supports multiple tablespaces, then this360upgrading to an InnoDB version which supports multiple tablespaces, then this
@@ -358,10 +375,20 @@
358 byte* page;375 byte* page;
359 ibool reset_space_ids = FALSE;376 ibool reset_space_ids = FALSE;
360 byte* doublewrite;377 byte* doublewrite;
378 ulint doublewrite_space_id;
361 ulint space_id;379 ulint space_id;
362 ulint page_no;380 ulint page_no;
363 ulint i;381 ulint i;
364382
383 if (srv_doublewrite_file) {
384 doublewrite_space_id = TRX_DOUBLEWRITE_SPACE;
385 fprintf(stderr,
386 "InnoDB: doublewrite file '%s' is used.\n",
387 srv_doublewrite_file);
388 } else {
389 doublewrite_space_id = TRX_SYS_SPACE;
390 }
391
365 /* We do the file i/o past the buffer pool */392 /* We do the file i/o past the buffer pool */
366393
367 unaligned_read_buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE));394 unaligned_read_buf = static_cast<byte*>(ut_malloc(2 * UNIV_PAGE_SIZE));
@@ -372,7 +399,7 @@
372 /* Read the trx sys header to check if we are using the doublewrite399 /* Read the trx sys header to check if we are using the doublewrite
373 buffer */400 buffer */
374401
375 fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, TRX_SYS_PAGE_NO, 0,402 fil_io(OS_FILE_READ, TRUE, doublewrite_space_id, 0, TRX_SYS_PAGE_NO, 0,
376 UNIV_PAGE_SIZE, read_buf, NULL);403 UNIV_PAGE_SIZE, read_buf, NULL);
377 doublewrite = read_buf + TRX_SYS_DOUBLEWRITE;404 doublewrite = read_buf + TRX_SYS_DOUBLEWRITE;
378405
@@ -408,10 +435,10 @@
408435
409 /* Read the pages from the doublewrite buffer to memory */436 /* Read the pages from the doublewrite buffer to memory */
410437
411 fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, block1, 0,438 fil_io(OS_FILE_READ, TRUE, doublewrite_space_id, 0, block1, 0,
412 TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,439 TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
413 buf, NULL);440 buf, NULL);
414 fil_io(OS_FILE_READ, TRUE, TRX_SYS_SPACE, 0, block2, 0,441 fil_io(OS_FILE_READ, TRUE, doublewrite_space_id, 0, block2, 0,
415 TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,442 TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
416 buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,443 buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE,
417 NULL);444 NULL);
@@ -467,7 +494,8 @@
467 " doublewrite buf.\n",494 " doublewrite buf.\n",
468 (ulong) space_id, (ulong) page_no, (ulong) i);495 (ulong) space_id, (ulong) page_no, (ulong) i);
469496
470 } else if (space_id == TRX_SYS_SPACE497 } else if ((space_id == TRX_SYS_SPACE
498 || (srv_doublewrite_file && space_id == TRX_DOUBLEWRITE_SPACE))
471 && ((page_no >= block1499 && ((page_no >= block1
472 && page_no500 && page_no
473 < block1 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE)501 < block1 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE)
@@ -751,6 +779,13 @@
751 ulint len;779 ulint len;
752 ulint len2;780 ulint len2;
753 ulint i;781 ulint i;
782 ulint doublewrite_space_id;
783
784 if (srv_doublewrite_file) {
785 doublewrite_space_id = TRX_DOUBLEWRITE_SPACE;
786 } else {
787 doublewrite_space_id = TRX_SYS_SPACE;
788 }
754789
755 if (!srv_use_doublewrite_buf || buf_dblwr == NULL) {790 if (!srv_use_doublewrite_buf || buf_dblwr == NULL) {
756 /* Sync the writes to the disk. */791 /* Sync the writes to the disk. */
@@ -823,7 +858,7 @@
823 len = ut_min(TRX_SYS_DOUBLEWRITE_BLOCK_SIZE,858 len = ut_min(TRX_SYS_DOUBLEWRITE_BLOCK_SIZE,
824 buf_dblwr->first_free) * UNIV_PAGE_SIZE;859 buf_dblwr->first_free) * UNIV_PAGE_SIZE;
825860
826 fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,861 fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0,
827 buf_dblwr->block1, 0, len,862 buf_dblwr->block1, 0, len,
828 (void*) write_buf, NULL);863 (void*) write_buf, NULL);
829864
@@ -839,7 +874,7 @@
839 write_buf = buf_dblwr->write_buf874 write_buf = buf_dblwr->write_buf
840 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE;875 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE;
841876
842 fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,877 fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0,
843 buf_dblwr->block2, 0, len,878 buf_dblwr->block2, 0, len,
844 (void*) write_buf, NULL);879 (void*) write_buf, NULL);
845880
@@ -849,7 +884,7 @@
849 srv_stats.dblwr_writes.inc();884 srv_stats.dblwr_writes.inc();
850885
851 /* Now flush the doublewrite buffer data to disk */886 /* Now flush the doublewrite buffer data to disk */
852 fil_flush(TRX_SYS_SPACE);887 fil_flush(doublewrite_space_id);
853888
854 /* We know that the writes have been flushed to disk now889 /* We know that the writes have been flushed to disk now
855 and in recovery we will find them in the doublewrite buffer890 and in recovery we will find them in the doublewrite buffer
@@ -967,6 +1002,13 @@
967 ulint zip_size;1002 ulint zip_size;
968 ulint offset;1003 ulint offset;
969 ulint i;1004 ulint i;
1005 ulint doublewrite_space_id;
1006
1007 if (srv_doublewrite_file) {
1008 doublewrite_space_id = TRX_DOUBLEWRITE_SPACE;
1009 } else {
1010 doublewrite_space_id = TRX_SYS_SPACE;
1011 }
9701012
971 ut_a(buf_page_in_file(bpage));1013 ut_a(buf_page_in_file(bpage));
972 ut_a(srv_use_doublewrite_buf);1014 ut_a(srv_use_doublewrite_buf);
@@ -1046,21 +1088,21 @@
1046 memset(buf_dblwr->write_buf + UNIV_PAGE_SIZE * i1088 memset(buf_dblwr->write_buf + UNIV_PAGE_SIZE * i
1047 + zip_size, 0, UNIV_PAGE_SIZE - zip_size);1089 + zip_size, 0, UNIV_PAGE_SIZE - zip_size);
10481090
1049 fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,1091 fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0,
1050 offset, 0, UNIV_PAGE_SIZE,1092 offset, 0, UNIV_PAGE_SIZE,
1051 (void*) (buf_dblwr->write_buf1093 (void*) (buf_dblwr->write_buf
1052 + UNIV_PAGE_SIZE * i), NULL);1094 + UNIV_PAGE_SIZE * i), NULL);
1053 } else {1095 } else {
1054 /* It is a regular page. Write it directly to the1096 /* It is a regular page. Write it directly to the
1055 doublewrite buffer */1097 doublewrite buffer */
1056 fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0,1098 fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0,
1057 offset, 0, UNIV_PAGE_SIZE,1099 offset, 0, UNIV_PAGE_SIZE,
1058 (void*) ((buf_block_t*) bpage)->frame,1100 (void*) ((buf_block_t*) bpage)->frame,
1059 NULL);1101 NULL);
1060 }1102 }
10611103
1062 /* Now flush the doublewrite buffer data to disk */1104 /* Now flush the doublewrite buffer data to disk */
1063 fil_flush(TRX_SYS_SPACE);1105 fil_flush(doublewrite_space_id);
10641106
1065 /* We know that the write has been flushed to disk now1107 /* We know that the write has been flushed to disk now
1066 and during recovery we will find it in the doublewrite buffer1108 and during recovery we will find it in the doublewrite buffer
10671109
=== modified file 'Percona-Server/storage/innobase/buf/buf0rea.cc'
--- Percona-Server/storage/innobase/buf/buf0rea.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/buf/buf0rea.cc 2012-11-13 06:02:21 +0000
@@ -133,7 +133,9 @@
133 ignore_nonexistent_pages = mode & BUF_READ_IGNORE_NONEXISTENT_PAGES;133 ignore_nonexistent_pages = mode & BUF_READ_IGNORE_NONEXISTENT_PAGES;
134 mode &= ~BUF_READ_IGNORE_NONEXISTENT_PAGES;134 mode &= ~BUF_READ_IGNORE_NONEXISTENT_PAGES;
135135
136 if (space == TRX_SYS_SPACE && buf_dblwr_page_inside(offset)) {136 if ((space == TRX_SYS_SPACE
137 || (srv_doublewrite_file && space == TRX_DOUBLEWRITE_SPACE))
138 && buf_dblwr_page_inside(offset)) {
137 ut_print_timestamp(stderr);139 ut_print_timestamp(stderr);
138 fprintf(stderr,140 fprintf(stderr,
139 " InnoDB: Warning: trying to read"141 " InnoDB: Warning: trying to read"
140142
=== modified file 'Percona-Server/storage/innobase/dict/dict0load.cc'
--- Percona-Server/storage/innobase/dict/dict0load.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/dict/dict0load.cc 2012-11-13 06:02:21 +0000
@@ -45,6 +45,7 @@
45#include "dict0priv.h"45#include "dict0priv.h"
46#include "ha_prototypes.h" /* innobase_casedn_str() */46#include "ha_prototypes.h" /* innobase_casedn_str() */
47#include "fts0priv.h"47#include "fts0priv.h"
48#include "trx0sys.h"
4849
49/** Following are the InnoDB system tables. The positions in50/** Following are the InnoDB system tables. The positions in
50this array are referenced by enum dict_system_table_id. */51this array are referenced by enum dict_system_table_id. */
@@ -1066,7 +1067,7 @@
1066 discarded = !!(flags2 & DICT_TF2_DISCARDED);1067 discarded = !!(flags2 & DICT_TF2_DISCARDED);
1067 }1068 }
10681069
1069 if (space_id == 0) {1070 if (trx_sys_sys_space(space_id)) {
1070 /* The system tablespace always exists. */1071 /* The system tablespace always exists. */
1071 ut_ad(!discarded);1072 ut_ad(!discarded);
1072 } else if (in_crash_recovery) {1073 } else if (in_crash_recovery) {
@@ -2248,7 +2249,7 @@
2248 btr_pcur_close(&pcur);2249 btr_pcur_close(&pcur);
2249 mtr_commit(&mtr);2250 mtr_commit(&mtr);
22502251
2251 if (table->space == 0) {2252 if (trx_sys_sys_space(table->space)) {
2252 /* The system tablespace is always available. */2253 /* The system tablespace is always available. */
2253 } else if (table->flags2 & DICT_TF2_DISCARDED) {2254 } else if (table->flags2 & DICT_TF2_DISCARDED) {
22542255
22552256
=== modified file 'Percona-Server/storage/innobase/fil/fil0fil.cc'
--- Percona-Server/storage/innobase/fil/fil0fil.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/fil/fil0fil.cc 2012-11-13 06:02:21 +0000
@@ -308,7 +308,7 @@
308static fil_system_t* fil_system = NULL;308static fil_system_t* fil_system = NULL;
309309
310/** Determine if (i) is a user tablespace id or not. */310/** Determine if (i) is a user tablespace id or not. */
311# define fil_is_user_tablespace_id(i) ((i) > srv_undo_tablespaces_open)311# define fil_is_user_tablespace_id(i) ((i) > srv_undo_tablespaces_open && !trx_sys_sys_space(i))
312312
313/** Determine if user has explicitly disabled fsync(). */313/** Determine if user has explicitly disabled fsync(). */
314#ifndef __WIN__314#ifndef __WIN__
@@ -668,7 +668,7 @@
668668
669 UT_LIST_ADD_LAST(chain, space->chain, node);669 UT_LIST_ADD_LAST(chain, space->chain, node);
670670
671 if (id < SRV_LOG_SPACE_FIRST_ID && fil_system->max_assigned_id < id) {671 if (id < SRV_EXTRA_SYS_SPACE_FIRST_ID && fil_system->max_assigned_id < id) {
672672
673 fil_system->max_assigned_id = id;673 fil_system->max_assigned_id = id;
674 }674 }
@@ -729,14 +729,14 @@
729 size_bytes = os_file_get_size(node->handle);729 size_bytes = os_file_get_size(node->handle);
730 ut_a(size_bytes != (os_offset_t) -1);730 ut_a(size_bytes != (os_offset_t) -1);
731#ifdef UNIV_HOTBACKUP731#ifdef UNIV_HOTBACKUP
732 if (space->id == 0) {732 if (trx_sys_sys_space(space->id)) {
733 node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);733 node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE);
734 os_file_close(node->handle);734 os_file_close(node->handle);
735 goto add_size;735 goto add_size;
736 }736 }
737#endif /* UNIV_HOTBACKUP */737#endif /* UNIV_HOTBACKUP */
738 ut_a(space->purpose != FIL_LOG);738 ut_a(space->purpose != FIL_LOG);
739 ut_a(fil_is_user_tablespace_id(space->id));739 ut_a(!trx_sys_sys_space(space->id));
740740
741 if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {741 if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) {
742 fprintf(stderr,742 fprintf(stderr,
@@ -781,7 +781,7 @@
781 }781 }
782782
783 if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED783 if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED
784 || space_id == 0)) {784 || trx_sys_sys_space(space_id))) {
785 fprintf(stderr,785 fprintf(stderr,
786 "InnoDB: Error: tablespace id %lu"786 "InnoDB: Error: tablespace id %lu"
787 " in file %s is not sensible\n",787 " in file %s is not sensible\n",
@@ -864,7 +864,6 @@
864 fil_n_file_opened++;864 fil_n_file_opened++;
865865
866 if (fil_space_belongs_in_lru(space)) {866 if (fil_space_belongs_in_lru(space)) {
867
868 /* Put the node to the LRU list */867 /* Put the node to the LRU list */
869 UT_LIST_ADD_FIRST(LRU, system->LRU, node);868 UT_LIST_ADD_FIRST(LRU, system->LRU, node);
870 }869 }
@@ -903,7 +902,6 @@
903 fil_n_file_opened--;902 fil_n_file_opened--;
904903
905 if (fil_space_belongs_in_lru(node->space)) {904 if (fil_space_belongs_in_lru(node->space)) {
906
907 ut_a(UT_LIST_GET_LEN(system->LRU) > 0);905 ut_a(UT_LIST_GET_LEN(system->LRU) > 0);
908906
909 /* The node is in the LRU list, remove it */907 /* The node is in the LRU list, remove it */
@@ -999,7 +997,7 @@
999retry:997retry:
1000 mutex_enter(&fil_system->mutex);998 mutex_enter(&fil_system->mutex);
1001999
1002 if (space_id == 0 || space_id >= SRV_LOG_SPACE_FIRST_ID) {1000 if (trx_sys_sys_space(space_id) || space_id >= SRV_LOG_SPACE_FIRST_ID) {
1003 /* We keep log files and system tablespace files always open;1001 /* We keep log files and system tablespace files always open;
1004 this is important in preventing deadlocks in this module, as1002 this is important in preventing deadlocks in this module, as
1005 a page read completion often performs another read from the1003 a page read completion often performs another read from the
@@ -1276,9 +1274,9 @@
1276 space->tablespace_version = fil_system->tablespace_version;1274 space->tablespace_version = fil_system->tablespace_version;
1277 space->mark = FALSE;1275 space->mark = FALSE;
12781276
1279 if (purpose == FIL_TABLESPACE && !recv_recovery_on1277 if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on)
1280 && id > fil_system->max_assigned_id) {1278 && UNIV_UNLIKELY(id < SRV_EXTRA_SYS_SPACE_FIRST_ID)
12811279 && UNIV_UNLIKELY(id > fil_system->max_assigned_id)) {
1282 if (!fil_system->space_id_reuse_warned) {1280 if (!fil_system->space_id_reuse_warned) {
1283 fil_system->space_id_reuse_warned = TRUE;1281 fil_system->space_id_reuse_warned = TRUE;
12841282
@@ -1350,7 +1348,7 @@
1350 (ulong) SRV_LOG_SPACE_FIRST_ID);1348 (ulong) SRV_LOG_SPACE_FIRST_ID);
1351 }1349 }
13521350
1353 success = (id < SRV_LOG_SPACE_FIRST_ID);1351 success = (id < SRV_EXTRA_SYS_SPACE_FIRST_ID);
13541352
1355 if (success) {1353 if (success) {
1356 *space_id = fil_system->max_assigned_id = id;1354 *space_id = fil_system->max_assigned_id = id;
@@ -1773,6 +1771,10 @@
1773 ut_error;1771 ut_error;
1774 }1772 }
17751773
1774 if (max_id >= SRV_EXTRA_SYS_SPACE_FIRST_ID) {
1775 return;
1776 }
1777
1776 mutex_enter(&fil_system->mutex);1778 mutex_enter(&fil_system->mutex);
17771779
1778 if (fil_system->max_assigned_id < max_id) {1780 if (fil_system->max_assigned_id < max_id) {
@@ -4067,7 +4069,7 @@
4067 }4069 }
40684070
4069#ifdef UNIV_HOTBACKUP4071#ifdef UNIV_HOTBACKUP
4070 if (fsp->id == ULINT_UNDEFINED || fsp->id == 0) {4072 if (fsp->id == ULINT_UNDEFINED || trx_sys_sys_space(fsp->id)) {
4071 char* new_path;4073 char* new_path;
40724074
4073 fprintf(stderr,4075 fprintf(stderr,
@@ -4967,7 +4969,6 @@
4967 }4969 }
49684970
4969 if (node->n_pending == 0 && fil_space_belongs_in_lru(node->space)) {4971 if (node->n_pending == 0 && fil_space_belongs_in_lru(node->space)) {
4970
4971 /* The node must be put back to the LRU list */4972 /* The node must be put back to the LRU list */
4972 UT_LIST_ADD_FIRST(LRU, system->LRU, node);4973 UT_LIST_ADD_FIRST(LRU, system->LRU, node);
4973 }4974 }
49744975
=== modified file 'Percona-Server/storage/innobase/fsp/fsp0fsp.cc'
--- Percona-Server/storage/innobase/fsp/fsp0fsp.cc 2012-08-22 01:40:20 +0000
+++ Percona-Server/storage/innobase/fsp/fsp0fsp.cc 2012-11-13 06:02:21 +0000
@@ -49,7 +49,7 @@
49#endif /* UNIV_HOTBACKUP */49#endif /* UNIV_HOTBACKUP */
50#include "dict0mem.h"50#include "dict0mem.h"
51#include "srv0start.h"51#include "srv0start.h"
5252#include "trx0sys.h"
5353
54#ifndef UNIV_HOTBACKUP54#ifndef UNIV_HOTBACKUP
55/** Flag to indicate if we have printed the tablespace full error. */55/** Flag to indicate if we have printed the tablespace full error. */
@@ -832,10 +832,10 @@
832 flst_init(header + FSP_SEG_INODES_FREE, mtr);832 flst_init(header + FSP_SEG_INODES_FREE, mtr);
833833
834 mlog_write_ull(header + FSP_SEG_ID, 1, mtr);834 mlog_write_ull(header + FSP_SEG_ID, 1, mtr);
835 if (space == 0) {835 if (space == TRX_SYS_SPACE || space == TRX_DOUBLEWRITE_SPACE) {
836 fsp_fill_free_list(FALSE, space, header, mtr);836 fsp_fill_free_list(FALSE, space, header, mtr);
837 btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,837 btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF,
838 0, 0, DICT_IBUF_ID_MIN + space,838 space, 0, DICT_IBUF_ID_MIN + space,
839 dict_ind_redundant, mtr);839 dict_ind_redundant, mtr);
840 } else {840 } else {
841 fsp_fill_free_list(TRUE, space, header, mtr);841 fsp_fill_free_list(TRUE, space, header, mtr);
842842
=== modified file 'Percona-Server/storage/innobase/handler/ha_innodb.cc'
--- Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/handler/ha_innodb.cc 2012-11-13 06:02:21 +0000
@@ -159,6 +159,7 @@
159static char* innobase_disable_monitor_counter = NULL;159static char* innobase_disable_monitor_counter = NULL;
160static char* innobase_reset_monitor_counter = NULL;160static char* innobase_reset_monitor_counter = NULL;
161static char* innobase_reset_all_monitor_counter = NULL;161static char* innobase_reset_all_monitor_counter = NULL;
162static char* innobase_doublewrite_file = NULL;
162163
163/* The highest file format being used in the database. The value can be164/* The highest file format being used in the database. The value can be
164set by user, however, it will be adjusted to the newer file format if165set by user, however, it will be adjusted to the newer file format if
@@ -2920,6 +2921,8 @@
2920 goto error;2921 goto error;
2921 }2922 }
29222923
2924 srv_doublewrite_file = innobase_doublewrite_file;
2925
2923 /* -------------- All log files ---------------------------*/2926 /* -------------- All log files ---------------------------*/
29242927
2925 /* The default dir for log files is the datadir of MySQL */2928 /* The default dir for log files is the datadir of MySQL */
@@ -15799,6 +15802,11 @@
15799 1, /* Minimum value */15802 1, /* Minimum value */
15800 TRX_SYS_N_RSEGS, 0); /* Maximum value */15803 TRX_SYS_N_RSEGS, 0); /* Maximum value */
1580115804
15805static MYSQL_SYSVAR_STR(doublewrite_file, innobase_doublewrite_file,
15806 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
15807 "Path to special datafile for doublewrite buffer. (default is "": not used) ### ONLY FOR EXPERTS!!! ###",
15808 NULL, NULL, NULL);
15809
15802static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,15810static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
15803 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,15811 PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
15804 "The AUTOINC lock modes supported by InnoDB: "15812 "The AUTOINC lock modes supported by InnoDB: "
@@ -15980,6 +15988,7 @@
15980 MYSQL_SYSVAR(concurrency_tickets),15988 MYSQL_SYSVAR(concurrency_tickets),
15981 MYSQL_SYSVAR(compression_level),15989 MYSQL_SYSVAR(compression_level),
15982 MYSQL_SYSVAR(data_file_path),15990 MYSQL_SYSVAR(data_file_path),
15991 MYSQL_SYSVAR(doublewrite_file),
15983 MYSQL_SYSVAR(data_home_dir),15992 MYSQL_SYSVAR(data_home_dir),
15984 MYSQL_SYSVAR(doublewrite),15993 MYSQL_SYSVAR(doublewrite),
15985 MYSQL_SYSVAR(api_enable_binlog),15994 MYSQL_SYSVAR(api_enable_binlog),
1598615995
=== modified file 'Percona-Server/storage/innobase/include/mtr0log.ic'
--- Percona-Server/storage/innobase/include/mtr0log.ic 2012-01-26 11:57:53 +0000
+++ Percona-Server/storage/innobase/include/mtr0log.ic 2012-11-13 06:02:21 +0000
@@ -28,8 +28,8 @@
28#include "buf0buf.h"28#include "buf0buf.h"
29#include "buf0dblwr.h"29#include "buf0dblwr.h"
30#include "fsp0types.h"30#include "fsp0types.h"
31#include "srv0srv.h"
31#include "trx0sys.h"32#include "trx0sys.h"
32
33/********************************************************//**33/********************************************************//**
34Opens a buffer to mlog. It must be closed with mlog_close.34Opens a buffer to mlog. It must be closed with mlog_close.
35@return buffer, NULL if log mode MTR_LOG_NONE */35@return buffer, NULL if log mode MTR_LOG_NONE */
@@ -202,7 +202,8 @@
202 the doublewrite buffer is located in pages202 the doublewrite buffer is located in pages
203 FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the203 FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the
204 system tablespace */204 system tablespace */
205 if (space == TRX_SYS_SPACE205 if ((space == TRX_SYS_SPACE
206 || (srv_doublewrite_file && space == TRX_DOUBLEWRITE_SPACE))
206 && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) {207 && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) {
207 if (buf_dblwr_being_created) {208 if (buf_dblwr_being_created) {
208 /* Do nothing: we only come to this branch in an209 /* Do nothing: we only come to this branch in an
209210
=== modified file 'Percona-Server/storage/innobase/include/srv0srv.h'
--- Percona-Server/storage/innobase/include/srv0srv.h 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/include/srv0srv.h 2012-11-13 06:02:21 +0000
@@ -235,6 +235,8 @@
235extern ulint* srv_data_file_sizes;235extern ulint* srv_data_file_sizes;
236extern ulint* srv_data_file_is_raw_partition;236extern ulint* srv_data_file_is_raw_partition;
237237
238extern char* srv_doublewrite_file;
239
238extern ibool srv_auto_extend_last_data_file;240extern ibool srv_auto_extend_last_data_file;
239extern ulint srv_last_file_size_max;241extern ulint srv_last_file_size_max;
240extern char** srv_log_group_home_dirs;242extern char** srv_log_group_home_dirs;
241243
=== modified file 'Percona-Server/storage/innobase/include/srv0start.h'
--- Percona-Server/storage/innobase/include/srv0start.h 2012-08-22 01:40:20 +0000
+++ Percona-Server/storage/innobase/include/srv0start.h 2012-11-13 06:02:21 +0000
@@ -173,4 +173,7 @@
173/** Log 'spaces' have id's >= this */173/** Log 'spaces' have id's >= this */
174#define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0UL174#define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0UL
175175
176/** reserved for extra system tables */
177#define SRV_EXTRA_SYS_SPACE_FIRST_ID 0xFFFFFFE0UL
178
176#endif179#endif
177180
=== modified file 'Percona-Server/storage/innobase/include/trx0sys.h'
--- Percona-Server/storage/innobase/include/trx0sys.h 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/include/trx0sys.h 2012-11-13 06:02:21 +0000
@@ -78,6 +78,22 @@
78/*=============*/78/*=============*/
79 ulint space, /*!< in: space */79 ulint space, /*!< in: space */
80 ulint page_no);/*!< in: page number */80 ulint page_no);/*!< in: page number */
81/***************************************************************//**
82Checks if a space is the system tablespaces.
83@return TRUE if system tablespace */
84UNIV_INLINE
85ibool
86trx_sys_sys_space(
87/*==============*/
88 ulint space); /*!< in: space */
89/***************************************************************//**
90Checks if a space is the doublewrite tablespace.
91@return TRUE if doublewrite tablespace */
92UNIV_INLINE
93ibool
94trx_sys_doublewrite_space(
95/*======================*/
96 ulint space); /*!< in: space */
81/*****************************************************************//**97/*****************************************************************//**
82Creates and initializes the central memory structures for the transaction98Creates and initializes the central memory structures for the transaction
83system. This is called when the database is started.99system. This is called when the database is started.
@@ -463,6 +479,8 @@
463479
464/* Space id and page no where the trx system file copy resides */480/* Space id and page no where the trx system file copy resides */
465#define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */481#define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */
482#define TRX_DOUBLEWRITE_SPACE 0xFFFFFFE0UL /* the doublewrite buffer tablespace if used */
483#define TRX_SYS_SPACE_MAX 9 /* reserved max space id for system tablespaces */
466#include "fsp0fsp.h"484#include "fsp0fsp.h"
467#define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO485#define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO
468486
@@ -660,3 +678,9 @@
660#endif678#endif
661679
662#endif680#endif
681
682UNIV_INTERN
683void
684trx_sys_dummy_create(
685/*=================*/
686 ulint space);
663687
=== modified file 'Percona-Server/storage/innobase/include/trx0sys.ic'
--- Percona-Server/storage/innobase/include/trx0sys.ic 2011-11-21 00:04:40 +0000
+++ Percona-Server/storage/innobase/include/trx0sys.ic 2012-11-13 06:02:21 +0000
@@ -25,6 +25,7 @@
2525
26#include "trx0trx.h"26#include "trx0trx.h"
27#include "data0type.h"27#include "data0type.h"
28#include "srv0srv.h"
28#ifndef UNIV_HOTBACKUP29#ifndef UNIV_HOTBACKUP
29# include "srv0srv.h"30# include "srv0srv.h"
30# include "mtr0log.h"31# include "mtr0log.h"
@@ -71,6 +72,40 @@
71}72}
7273
73/***************************************************************//**74/***************************************************************//**
75Checks if a space is the system tablespaces.
76@return TRUE if system tablespace */
77UNIV_INLINE
78ibool
79trx_sys_sys_space(
80/*==============*/
81 ulint space) /*!< in: space */
82{
83 if (srv_doublewrite_file) {
84 /* several spaces are reserved */
85 return((ibool)(space == TRX_SYS_SPACE || space == TRX_DOUBLEWRITE_SPACE));
86 } else {
87 return((ibool)(space == TRX_SYS_SPACE));
88 }
89}
90
91/***************************************************************//**
92Checks if a space is the doublewrite tablespace.
93@return TRUE if doublewrite tablespace */
94UNIV_INLINE
95ibool
96trx_sys_doublewrite_space(
97/*======================*/
98 ulint space) /*!< in: space */
99{
100 if (srv_doublewrite_file) {
101 /* doublewrite buffer is separated */
102 return((ibool)(space == TRX_DOUBLEWRITE_SPACE));
103 } else {
104 return((ibool)(space == TRX_SYS_SPACE));
105 }
106}
107
108/***************************************************************//**
74Gets the pointer in the nth slot of the rseg array.109Gets the pointer in the nth slot of the rseg array.
75@return pointer to rseg object, NULL if slot not in use */110@return pointer to rseg object, NULL if slot not in use */
76UNIV_INLINE111UNIV_INLINE
77112
=== modified file 'Percona-Server/storage/innobase/row/row0mysql.cc'
--- Percona-Server/storage/innobase/row/row0mysql.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/row/row0mysql.cc 2012-11-13 06:02:21 +0000
@@ -4108,7 +4108,7 @@
4108 a temp table or if the tablesace has been discarded. */4108 a temp table or if the tablesace has been discarded. */
4109 print_msg = !(is_temp || ibd_file_missing);4109 print_msg = !(is_temp || ibd_file_missing);
41104110
4111 if (err == DB_SUCCESS && space_id > TRX_SYS_SPACE) {4111 if (err == DB_SUCCESS && !trx_sys_sys_space(space_id)) {
4112 if (!is_temp4112 if (!is_temp
4113 && !fil_space_for_table_exists_in_mem(4113 && !fil_space_for_table_exists_in_mem(
4114 space_id, tablename, FALSE, print_msg)) {4114 space_id, tablename, FALSE, print_msg)) {
41154115
=== modified file 'Percona-Server/storage/innobase/srv/srv0srv.cc'
--- Percona-Server/storage/innobase/srv/srv0srv.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/srv/srv0srv.cc 2012-11-13 06:02:21 +0000
@@ -161,6 +161,8 @@
161/* size in database pages */161/* size in database pages */
162UNIV_INTERN ulint* srv_data_file_sizes = NULL;162UNIV_INTERN ulint* srv_data_file_sizes = NULL;
163163
164UNIV_INTERN char* srv_doublewrite_file = NULL;
165
164/* if TRUE, then we auto-extend the last data file */166/* if TRUE, then we auto-extend the last data file */
165UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE;167UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE;
166/* if != 0, this tells the max size auto-extending may increase the168/* if != 0, this tells the max size auto-extending may increase the
167169
=== modified file 'Percona-Server/storage/innobase/srv/srv0start.cc'
--- Percona-Server/storage/innobase/srv/srv0start.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/srv/srv0start.cc 2012-11-13 06:02:21 +0000
@@ -761,6 +761,7 @@
761/*======================*/761/*======================*/
762 ibool* create_new_db, /*!< out: TRUE if new database should be762 ibool* create_new_db, /*!< out: TRUE if new database should be
763 created */763 created */
764 ibool* create_new_doublewrite_file,
764#ifdef UNIV_LOG_ARCHIVE765#ifdef UNIV_LOG_ARCHIVE
765 ulint* min_arch_log_no,/*!< out: min of archived log766 ulint* min_arch_log_no,/*!< out: min of archived log
766 numbers in data files */767 numbers in data files */
@@ -796,6 +797,7 @@
796 *sum_of_new_sizes = 0;797 *sum_of_new_sizes = 0;
797798
798 *create_new_db = FALSE;799 *create_new_db = FALSE;
800 *create_new_doublewrite_file = FALSE;
799801
800 srv_normalize_path_for_win(srv_data_home);802 srv_normalize_path_for_win(srv_data_home);
801803
@@ -1066,6 +1068,139 @@
1066 srv_data_file_is_raw_partition[i] != 0);1068 srv_data_file_is_raw_partition[i] != 0);
1067 }1069 }
10681070
1071 /* special file for doublewrite buffer */
1072 if (srv_doublewrite_file)
1073 {
1074 srv_normalize_path_for_win(srv_doublewrite_file);
1075
1076 fprintf(stderr,
1077 "InnoDB: Note: The innodb_doublewrite_file option has been specified.\n"
1078 "InnoDB: This option is for experts only. Don't use it unless you understand WELL what it is.\n"
1079 "InnoDB: ### Don't specify a file older than the last checkpoint. ###\n"
1080 "InnoDB: Otherwise, the older doublewrite buffer will break your data during recovery!\n");
1081
1082 strcpy(name, srv_doublewrite_file);
1083
1084 /* First we try to create the file: if it already
1085 exists, ret will get value FALSE */
1086
1087 files[i] = os_file_create(innodb_file_data_key, name, OS_FILE_CREATE,
1088 OS_FILE_NORMAL,
1089 OS_DATA_FILE, &ret);
1090
1091 if (ret == FALSE && os_file_get_last_error(FALSE)
1092 != OS_FILE_ALREADY_EXISTS
1093#ifdef UNIV_AIX
1094 /* AIX 5.1 after security patch ML7 may have
1095 errno set to 0 here, which causes our function
1096 to return 100; work around that AIX problem */
1097 && os_file_get_last_error(FALSE) != 100
1098#endif
1099 ) {
1100 fprintf(stderr,
1101 "InnoDB: Error in creating"
1102 " or opening %s\n",
1103 name);
1104
1105 return(DB_ERROR);
1106 }
1107
1108 if (ret == FALSE) {
1109 /* We open the data file */
1110
1111 files[i] = os_file_create(innodb_file_data_key,
1112 name, OS_FILE_OPEN, OS_FILE_NORMAL,
1113 OS_DATA_FILE, &ret);
1114
1115 if (!ret) {
1116 fprintf(stderr,
1117 "InnoDB: Error in opening %s\n", name);
1118 os_file_get_last_error(TRUE);
1119
1120 return(DB_ERROR);
1121 }
1122
1123 size = os_file_get_size(files[i]);
1124 /* Round size downward to megabytes */
1125
1126 rounded_size_pages = (ulint)
1127 (size >> UNIV_PAGE_SIZE_SHIFT);
1128
1129 if (rounded_size_pages != TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9) {
1130
1131 fprintf(stderr,
1132 "InnoDB: Warning: doublewrite buffer file %s"
1133 " is of a different size\n"
1134 "InnoDB: %lu pages"
1135 " (rounded down to MB)\n"
1136 "InnoDB: than intended size"
1137 " %lu pages...\n",
1138 name,
1139 (ulong) rounded_size_pages,
1140 (ulong) TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9);
1141 }
1142
1143 fil_read_first_page(files[i], one_opened, &flags,
1144 &space,
1145#ifdef UNIV_LOG_ARCHIVE
1146 min_arch_log_no, max_arch_log_no,
1147#endif /* UNIV_LOG_ARCHIVE */
1148 min_flushed_lsn, max_flushed_lsn);
1149 one_opened = TRUE;
1150 } else {
1151 /* We created the data file and now write it full of
1152 zeros */
1153
1154 *create_new_doublewrite_file = TRUE;
1155
1156 ut_print_timestamp(stderr);
1157 fprintf(stderr,
1158 " InnoDB: Doublewrite buffer file %s did not"
1159 " exist. It will be be created.\n",
1160 name);
1161
1162 if (*create_new_db == FALSE) {
1163 fprintf(stderr,
1164 "InnoDB: Notice: Previous version's ibdata files may cause crash.\n"
1165 " If you use that, please use the ibdata files of this version.\n");
1166 }
1167
1168 ut_print_timestamp(stderr);
1169 fprintf(stderr,
1170 " InnoDB: Setting file %s size to %lu MB\n",
1171 name,
1172 (ulong) ((TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9)
1173 >> (20 - UNIV_PAGE_SIZE_SHIFT)));
1174
1175 fprintf(stderr,
1176 "InnoDB: Database physically writes the"
1177 " file full: wait...\n");
1178
1179 ret = os_file_set_size(
1180 name, files[i],
1181 (TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9) << UNIV_PAGE_SIZE_SHIFT);
1182
1183 if (!ret) {
1184 fprintf(stderr,
1185 "InnoDB: Error in creating %s:"
1186 " probably out of disk space\n", name);
1187
1188 return(DB_ERROR);
1189 }
1190 }
1191
1192 ret = os_file_close(files[i]);
1193 ut_a(ret);
1194
1195 fil_space_create(name, TRX_DOUBLEWRITE_SPACE, 0, FIL_TABLESPACE);
1196
1197 ut_a(fil_validate());
1198
1199 fil_node_create(name, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, TRX_DOUBLEWRITE_SPACE, FALSE);
1200
1201 i++;
1202 }
1203
1069 return(DB_SUCCESS);1204 return(DB_SUCCESS);
1070}1205}
10711206
@@ -1448,6 +1583,7 @@
1448/*====================================*/1583/*====================================*/
1449{1584{
1450 ibool create_new_db;1585 ibool create_new_db;
1586 ibool create_new_doublewrite_file;
1451 ibool log_file_created;1587 ibool log_file_created;
1452 ibool log_created = FALSE;1588 ibool log_created = FALSE;
1453 ibool log_opened = FALSE;1589 ibool log_opened = FALSE;
@@ -1940,6 +2076,7 @@
1940 }2076 }
19412077
1942 err = open_or_create_data_files(&create_new_db,2078 err = open_or_create_data_files(&create_new_db,
2079 &create_new_doublewrite_file,
1943#ifdef UNIV_LOG_ARCHIVE2080#ifdef UNIV_LOG_ARCHIVE
1944 &min_arch_log_no, &max_arch_log_no,2081 &min_arch_log_no, &max_arch_log_no,
1945#endif /* UNIV_LOG_ARCHIVE */2082#endif /* UNIV_LOG_ARCHIVE */
@@ -2112,6 +2249,14 @@
21122249
2113 trx_purge_sys_create(srv_n_purge_threads, ib_bh);2250 trx_purge_sys_create(srv_n_purge_threads, ib_bh);
21142251
2252 if (create_new_doublewrite_file) {
2253 mtr_start(&mtr);
2254 fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr);
2255 mtr_commit(&mtr);
2256
2257 trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE);
2258 }
2259
2115 dict_create();2260 dict_create();
21162261
2117 srv_startup_is_before_trx_rollback_phase = FALSE;2262 srv_startup_is_before_trx_rollback_phase = FALSE;
@@ -2146,6 +2291,13 @@
2146 recv_recovery_from_archive_finish();2291 recv_recovery_from_archive_finish();
2147#endif /* UNIV_LOG_ARCHIVE */2292#endif /* UNIV_LOG_ARCHIVE */
2148 } else {2293 } else {
2294 char* save_srv_doublewrite_file = NULL;
2295
2296 if (create_new_doublewrite_file) {
2297 /* doublewrite_file cannot be used for recovery yet. */
2298 save_srv_doublewrite_file = srv_doublewrite_file;
2299 srv_doublewrite_file = NULL;
2300 }
21492301
2150 /* Check if we support the max format that is stamped2302 /* Check if we support the max format that is stamped
2151 on the system tablespace.2303 on the system tablespace.
@@ -2235,6 +2387,17 @@
2235 we have finished the recovery process so that the2387 we have finished the recovery process so that the
2236 image of TRX_SYS_PAGE_NO is not stale. */2388 image of TRX_SYS_PAGE_NO is not stale. */
2237 trx_sys_file_format_tag_init();2389 trx_sys_file_format_tag_init();
2390
2391 if (create_new_doublewrite_file) {
2392 /* restore the value */
2393 srv_doublewrite_file = save_srv_doublewrite_file;
2394
2395 mtr_start(&mtr);
2396 fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr);
2397 mtr_commit(&mtr);
2398
2399 trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE);
2400 }
2238 }2401 }
22392402
2240 if (!create_new_db && sum_of_new_sizes > 0) {2403 if (!create_new_db && sum_of_new_sizes > 0) {
22412404
=== modified file 'Percona-Server/storage/innobase/trx/trx0sys.cc'
--- Percona-Server/storage/innobase/trx/trx0sys.cc 2012-10-16 06:21:51 +0000
+++ Percona-Server/storage/innobase/trx/trx0sys.cc 2012-11-13 06:02:21 +0000
@@ -385,7 +385,8 @@
385void385void
386trx_sysf_create(386trx_sysf_create(
387/*============*/387/*============*/
388 mtr_t* mtr) /*!< in: mtr */388 mtr_t* mtr, /*!< in: mtr */
389 ulint space_id)
389{390{
390 trx_sysf_t* sys_header;391 trx_sysf_t* sys_header;
391 ulint slot_no;392 ulint slot_no;
@@ -401,10 +402,10 @@
401 then enter the kernel: we must do it in this order to conform402 then enter the kernel: we must do it in this order to conform
402 to the latching order rules. */403 to the latching order rules. */
403404
404 mtr_x_lock(fil_space_get_latch(TRX_SYS_SPACE, NULL), mtr);405 mtr_x_lock(fil_space_get_latch(space_id, NULL), mtr);
405406
406 /* Create the trx sys file block in a new allocated file segment */407 /* Create the trx sys file block in a new allocated file segment */
407 block = fseg_create(TRX_SYS_SPACE, 0, TRX_SYS + TRX_SYS_FSEG_HEADER,408 block = fseg_create(space_id, 0, TRX_SYS + TRX_SYS_FSEG_HEADER,
408 mtr);409 mtr);
409 buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER);410 buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER);
410411
@@ -422,6 +423,12 @@
422 mlog_write_ulint(page + TRX_SYS_DOUBLEWRITE423 mlog_write_ulint(page + TRX_SYS_DOUBLEWRITE
423 + TRX_SYS_DOUBLEWRITE_MAGIC, 0, MLOG_4BYTES, mtr);424 + TRX_SYS_DOUBLEWRITE_MAGIC, 0, MLOG_4BYTES, mtr);
424425
426 if (space_id != TRX_SYS_SPACE) {
427 /* That is all we need for doublewrite buffer file. */
428 ut_a(space_id == TRX_DOUBLEWRITE_SPACE);
429 return;
430 }
431
425 sys_header = trx_sysf_get(mtr);432 sys_header = trx_sysf_get(mtr);
426433
427 /* Start counting transaction ids from number 1 up */434 /* Start counting transaction ids from number 1 up */
@@ -445,7 +452,7 @@
445452
446 /* Create the first rollback segment in the SYSTEM tablespace */453 /* Create the first rollback segment in the SYSTEM tablespace */
447 slot_no = trx_sysf_rseg_find_free(mtr);454 slot_no = trx_sysf_rseg_find_free(mtr);
448 page_no = trx_rseg_header_create(TRX_SYS_SPACE, 0, ULINT_MAX, slot_no,455 page_no = trx_rseg_header_create(space_id, 0, ULINT_MAX, slot_no,
449 mtr);456 mtr);
450457
451 ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID);458 ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID);
@@ -599,7 +606,7 @@
599606
600 mtr_start(&mtr);607 mtr_start(&mtr);
601608
602 trx_sysf_create(&mtr);609 trx_sysf_create(&mtr, TRX_SYS_SPACE);
603610
604 mtr_commit(&mtr);611 mtr_commit(&mtr);
605}612}
@@ -863,6 +870,26 @@
863 /* Does nothing at the moment */870 /* Does nothing at the moment */
864}871}
865872
873/*****************************************************************//**
874Creates and initializes the dummy transaction system page for tablespace. */
875UNIV_INTERN
876void
877trx_sys_dummy_create(
878/*=================*/
879 ulint space)
880{
881 mtr_t mtr;
882
883 /* This function is only for doublewrite file for now */
884 ut_a(space == TRX_DOUBLEWRITE_SPACE);
885
886 mtr_start(&mtr);
887
888 trx_sysf_create(&mtr, space);
889
890 mtr_commit(&mtr);
891}
892
866/*********************************************************************893/*********************************************************************
867Creates the rollback segments.894Creates the rollback segments.
868@return number of rollback segments that are active. */895@return number of rollback segments that are active. */

Subscribers

People subscribed via source and target branches