Merge lp:~stewart/percona-server/5.6-doublewrite into lp:percona-server/5.6
- 5.6-doublewrite
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Laurynas Biveinis (community) | Needs Fixing | ||
Review via email: mp+134040@code.launchpad.net |
Commit message
Description of the change
Port innodb_
To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote : | # |
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 | 1 | show variables like 'innodb_doublewrite_file%'; | ||
6 | 2 | Variable_name Value | ||
7 | 3 | innodb_doublewrite_file ib_doublewrite | ||
8 | 4 | create table t1 (a int primary key auto_increment, b varchar(100)) engine=innodb; | ||
9 | 5 | insert into t1 (b) values ("hello"); | ||
10 | 6 | insert into t1 (b) values ("cruel"); | ||
11 | 7 | insert into t1 (b) values ("world"); | ||
12 | 8 | select * from t1 order by a; | ||
13 | 9 | a b | ||
14 | 10 | 1 hello | ||
15 | 11 | 2 cruel | ||
16 | 12 | 3 world | ||
17 | 13 | drop table t1; | ||
18 | 0 | 14 | ||
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 | 1 | --innodb_doublewrite_file=ib_doublewrite | ||
24 | 0 | 2 | ||
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 | 1 | --source include/have_innodb.inc | ||
30 | 2 | show variables like 'innodb_doublewrite_file%'; | ||
31 | 3 | |||
32 | 4 | create table t1 (a int primary key auto_increment, b varchar(100)) engine=innodb; | ||
33 | 5 | |||
34 | 6 | insert into t1 (b) values ("hello"); | ||
35 | 7 | insert into t1 (b) values ("cruel"); | ||
36 | 8 | insert into t1 (b) values ("world"); | ||
37 | 9 | |||
38 | 10 | select * from t1 order by a; | ||
39 | 11 | |||
40 | 12 | drop table t1; | ||
41 | 0 | 13 | ||
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 | 1 | show variables like 'innodb_doublewrite_file%'; | ||
47 | 2 | Variable_name Value | ||
48 | 3 | innodb_doublewrite_file ib_doublewrite | ||
49 | 0 | 4 | ||
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 | 1 | --innodb_doublewrite_file=ib_doublewrite | ||
55 | 0 | 2 | ||
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 | 1 | --source include/have_innodb.inc | ||
61 | 2 | show variables like 'innodb_doublewrite_file%'; | ||
62 | 0 | 3 | ||
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 | 3951 | read_space_id = mach_read_from_4( | 3951 | read_space_id = mach_read_from_4( |
68 | 3952 | frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); | 3952 | frame + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID); |
69 | 3953 | 3953 | ||
71 | 3954 | if (bpage->space == TRX_SYS_SPACE | 3954 | if ((bpage->space == TRX_SYS_SPACE |
72 | 3955 | || (srv_doublewrite_file && bpage->space == TRX_DOUBLEWRITE_SPACE)) | ||
73 | 3955 | && buf_dblwr_page_inside(bpage->offset)) { | 3956 | && buf_dblwr_page_inside(bpage->offset)) { |
74 | 3956 | 3957 | ||
75 | 3957 | ut_print_timestamp(stderr); | 3958 | ut_print_timestamp(stderr); |
76 | 3958 | 3959 | ||
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 | 93 | byte* | 93 | byte* |
82 | 94 | buf_dblwr_get( | 94 | buf_dblwr_get( |
83 | 95 | /*==========*/ | 95 | /*==========*/ |
84 | 96 | ulint space_id, | ||
85 | 96 | mtr_t* mtr) /*!< in/out: MTR to hold the page latch */ | 97 | mtr_t* mtr) /*!< in/out: MTR to hold the page latch */ |
86 | 97 | { | 98 | { |
87 | 98 | buf_block_t* block; | 99 | buf_block_t* block; |
88 | 99 | 100 | ||
90 | 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, |
91 | 101 | RW_X_LATCH, mtr); | 102 | RW_X_LATCH, mtr); |
92 | 102 | buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); | 103 | buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); |
93 | 103 | 104 | ||
94 | @@ -157,9 +158,9 @@ | |||
95 | 157 | /****************************************************************//** | 158 | /****************************************************************//** |
96 | 158 | Creates the doublewrite buffer to a new InnoDB installation. The header of the | 159 | Creates the doublewrite buffer to a new InnoDB installation. The header of the |
97 | 159 | doublewrite buffer is placed on the trx system header page. */ | 160 | doublewrite buffer is placed on the trx system header page. */ |
99 | 160 | UNIV_INTERN | 161 | static |
100 | 161 | void | 162 | void |
102 | 162 | buf_dblwr_create(void) | 163 | buf_dblwr_create_low(ulint space_id) |
103 | 163 | /*==================*/ | 164 | /*==================*/ |
104 | 164 | { | 165 | { |
105 | 165 | buf_block_t* block2; | 166 | buf_block_t* block2; |
106 | @@ -171,24 +172,20 @@ | |||
107 | 171 | ulint i; | 172 | ulint i; |
108 | 172 | mtr_t mtr; | 173 | mtr_t mtr; |
109 | 173 | 174 | ||
110 | 174 | if (buf_dblwr) { | ||
111 | 175 | /* Already inited */ | ||
112 | 176 | |||
113 | 177 | return; | ||
114 | 178 | } | ||
115 | 179 | |||
116 | 180 | start_again: | 175 | start_again: |
117 | 181 | mtr_start(&mtr); | 176 | mtr_start(&mtr); |
118 | 182 | buf_dblwr_being_created = TRUE; | 177 | buf_dblwr_being_created = TRUE; |
119 | 183 | 178 | ||
121 | 184 | doublewrite = buf_dblwr_get(&mtr); | 179 | doublewrite = buf_dblwr_get(space_id, &mtr); |
122 | 185 | 180 | ||
123 | 186 | if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC) | 181 | if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC) |
124 | 187 | == TRX_SYS_DOUBLEWRITE_MAGIC_N) { | 182 | == TRX_SYS_DOUBLEWRITE_MAGIC_N) { |
125 | 188 | /* The doublewrite buffer has already been created: | 183 | /* The doublewrite buffer has already been created: |
126 | 189 | just read in some numbers */ | 184 | just read in some numbers */ |
127 | 190 | 185 | ||
129 | 191 | buf_dblwr_init(doublewrite); | 186 | if (space_id == TRX_SYS_SPACE) { |
130 | 187 | buf_dblwr_init(doublewrite); | ||
131 | 188 | } | ||
132 | 192 | 189 | ||
133 | 193 | mtr_commit(&mtr); | 190 | mtr_commit(&mtr); |
134 | 194 | buf_dblwr_being_created = FALSE; | 191 | buf_dblwr_being_created = FALSE; |
135 | @@ -197,8 +194,8 @@ | |||
136 | 197 | 194 | ||
137 | 198 | ut_print_timestamp(stderr); | 195 | ut_print_timestamp(stderr); |
138 | 199 | fprintf(stderr, | 196 | fprintf(stderr, |
141 | 200 | " InnoDB: Doublewrite buffer not found:" | 197 | " InnoDB: Doublewrite buffer not found in tablespace (id %lu):" |
142 | 201 | " creating new\n"); | 198 | " creating new\n", space_id); |
143 | 202 | 199 | ||
144 | 203 | if (buf_pool_get_curr_size() | 200 | if (buf_pool_get_curr_size() |
145 | 204 | < ((2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE | 201 | < ((2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE |
146 | @@ -213,7 +210,7 @@ | |||
147 | 213 | exit(1); | 210 | exit(1); |
148 | 214 | } | 211 | } |
149 | 215 | 212 | ||
151 | 216 | block2 = fseg_create(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, | 213 | block2 = fseg_create(space_id, TRX_SYS_PAGE_NO, |
152 | 217 | TRX_SYS_DOUBLEWRITE | 214 | TRX_SYS_DOUBLEWRITE |
153 | 218 | + TRX_SYS_DOUBLEWRITE_FSEG, &mtr); | 215 | + TRX_SYS_DOUBLEWRITE_FSEG, &mtr); |
154 | 219 | 216 | ||
155 | @@ -303,7 +300,7 @@ | |||
156 | 303 | are active, restart the MTR occasionally. */ | 300 | are active, restart the MTR occasionally. */ |
157 | 304 | mtr_commit(&mtr); | 301 | mtr_commit(&mtr); |
158 | 305 | mtr_start(&mtr); | 302 | mtr_start(&mtr); |
160 | 306 | doublewrite = buf_dblwr_get(&mtr); | 303 | doublewrite = buf_dblwr_get(space_id, &mtr); |
161 | 307 | fseg_header = doublewrite | 304 | fseg_header = doublewrite |
162 | 308 | + TRX_SYS_DOUBLEWRITE_FSEG; | 305 | + TRX_SYS_DOUBLEWRITE_FSEG; |
163 | 309 | } | 306 | } |
164 | @@ -332,12 +329,32 @@ | |||
165 | 332 | buf_pool_invalidate(); | 329 | buf_pool_invalidate(); |
166 | 333 | 330 | ||
167 | 334 | ut_print_timestamp(stderr); | 331 | ut_print_timestamp(stderr); |
169 | 335 | fprintf(stderr, " InnoDB: Doublewrite buffer created\n"); | 332 | fprintf(stderr, " InnoDB: Doublewrite buffer created in tablespace id %lu\n", space_id); |
170 | 336 | 333 | ||
171 | 337 | goto start_again; | 334 | goto start_again; |
172 | 338 | } | 335 | } |
173 | 339 | 336 | ||
174 | 340 | /****************************************************************//** | 337 | /****************************************************************//** |
175 | 338 | Creates the doublewrite buffer to a new InnoDB installation. The header of the | ||
176 | 339 | doublewrite buffer is placed on the trx system header page. */ | ||
177 | 340 | UNIV_INTERN | ||
178 | 341 | void | ||
179 | 342 | buf_dblwr_create(void) | ||
180 | 343 | { | ||
181 | 344 | if (buf_dblwr) { | ||
182 | 345 | /* Already inited */ | ||
183 | 346 | |||
184 | 347 | return; | ||
185 | 348 | } | ||
186 | 349 | |||
187 | 350 | buf_dblwr_create_low(TRX_SYS_SPACE); | ||
188 | 351 | |||
189 | 352 | if (srv_doublewrite_file) { | ||
190 | 353 | buf_dblwr_create_low(TRX_DOUBLEWRITE_SPACE); | ||
191 | 354 | } | ||
192 | 355 | } | ||
193 | 356 | |||
194 | 357 | /****************************************************************//** | ||
195 | 341 | At a database startup initializes the doublewrite buffer memory structure if | 358 | At a database startup initializes the doublewrite buffer memory structure if |
196 | 342 | we already have a doublewrite buffer created in the data files. If we are | 359 | we already have a doublewrite buffer created in the data files. If we are |
197 | 343 | upgrading to an InnoDB version which supports multiple tablespaces, then this | 360 | upgrading to an InnoDB version which supports multiple tablespaces, then this |
198 | @@ -358,10 +375,20 @@ | |||
199 | 358 | byte* page; | 375 | byte* page; |
200 | 359 | ibool reset_space_ids = FALSE; | 376 | ibool reset_space_ids = FALSE; |
201 | 360 | byte* doublewrite; | 377 | byte* doublewrite; |
202 | 378 | ulint doublewrite_space_id; | ||
203 | 361 | ulint space_id; | 379 | ulint space_id; |
204 | 362 | ulint page_no; | 380 | ulint page_no; |
205 | 363 | ulint i; | 381 | ulint i; |
206 | 364 | 382 | ||
207 | 383 | if (srv_doublewrite_file) { | ||
208 | 384 | doublewrite_space_id = TRX_DOUBLEWRITE_SPACE; | ||
209 | 385 | fprintf(stderr, | ||
210 | 386 | "InnoDB: doublewrite file '%s' is used.\n", | ||
211 | 387 | srv_doublewrite_file); | ||
212 | 388 | } else { | ||
213 | 389 | doublewrite_space_id = TRX_SYS_SPACE; | ||
214 | 390 | } | ||
215 | 391 | |||
216 | 365 | /* We do the file i/o past the buffer pool */ | 392 | /* We do the file i/o past the buffer pool */ |
217 | 366 | 393 | ||
218 | 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)); |
219 | @@ -372,7 +399,7 @@ | |||
220 | 372 | /* Read the trx sys header to check if we are using the doublewrite | 399 | /* Read the trx sys header to check if we are using the doublewrite |
221 | 373 | buffer */ | 400 | buffer */ |
222 | 374 | 401 | ||
224 | 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, |
225 | 376 | UNIV_PAGE_SIZE, read_buf, NULL); | 403 | UNIV_PAGE_SIZE, read_buf, NULL); |
226 | 377 | doublewrite = read_buf + TRX_SYS_DOUBLEWRITE; | 404 | doublewrite = read_buf + TRX_SYS_DOUBLEWRITE; |
227 | 378 | 405 | ||
228 | @@ -408,10 +435,10 @@ | |||
229 | 408 | 435 | ||
230 | 409 | /* Read the pages from the doublewrite buffer to memory */ | 436 | /* Read the pages from the doublewrite buffer to memory */ |
231 | 410 | 437 | ||
233 | 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, |
234 | 412 | TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, | 439 | TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, |
235 | 413 | buf, NULL); | 440 | buf, NULL); |
237 | 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, |
238 | 415 | TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, | 442 | TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, |
239 | 416 | buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, | 443 | buf + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE, |
240 | 417 | NULL); | 444 | NULL); |
241 | @@ -467,7 +494,8 @@ | |||
242 | 467 | " doublewrite buf.\n", | 494 | " doublewrite buf.\n", |
243 | 468 | (ulong) space_id, (ulong) page_no, (ulong) i); | 495 | (ulong) space_id, (ulong) page_no, (ulong) i); |
244 | 469 | 496 | ||
246 | 470 | } else if (space_id == TRX_SYS_SPACE | 497 | } else if ((space_id == TRX_SYS_SPACE |
247 | 498 | || (srv_doublewrite_file && space_id == TRX_DOUBLEWRITE_SPACE)) | ||
248 | 471 | && ((page_no >= block1 | 499 | && ((page_no >= block1 |
249 | 472 | && page_no | 500 | && page_no |
250 | 473 | < block1 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) | 501 | < block1 + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE) |
251 | @@ -751,6 +779,13 @@ | |||
252 | 751 | ulint len; | 779 | ulint len; |
253 | 752 | ulint len2; | 780 | ulint len2; |
254 | 753 | ulint i; | 781 | ulint i; |
255 | 782 | ulint doublewrite_space_id; | ||
256 | 783 | |||
257 | 784 | if (srv_doublewrite_file) { | ||
258 | 785 | doublewrite_space_id = TRX_DOUBLEWRITE_SPACE; | ||
259 | 786 | } else { | ||
260 | 787 | doublewrite_space_id = TRX_SYS_SPACE; | ||
261 | 788 | } | ||
262 | 754 | 789 | ||
263 | 755 | if (!srv_use_doublewrite_buf || buf_dblwr == NULL) { | 790 | if (!srv_use_doublewrite_buf || buf_dblwr == NULL) { |
264 | 756 | /* Sync the writes to the disk. */ | 791 | /* Sync the writes to the disk. */ |
265 | @@ -823,7 +858,7 @@ | |||
266 | 823 | len = ut_min(TRX_SYS_DOUBLEWRITE_BLOCK_SIZE, | 858 | len = ut_min(TRX_SYS_DOUBLEWRITE_BLOCK_SIZE, |
267 | 824 | buf_dblwr->first_free) * UNIV_PAGE_SIZE; | 859 | buf_dblwr->first_free) * UNIV_PAGE_SIZE; |
268 | 825 | 860 | ||
270 | 826 | fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0, | 861 | fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0, |
271 | 827 | buf_dblwr->block1, 0, len, | 862 | buf_dblwr->block1, 0, len, |
272 | 828 | (void*) write_buf, NULL); | 863 | (void*) write_buf, NULL); |
273 | 829 | 864 | ||
274 | @@ -839,7 +874,7 @@ | |||
275 | 839 | write_buf = buf_dblwr->write_buf | 874 | write_buf = buf_dblwr->write_buf |
276 | 840 | + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE; | 875 | + TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * UNIV_PAGE_SIZE; |
277 | 841 | 876 | ||
279 | 842 | fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0, | 877 | fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0, |
280 | 843 | buf_dblwr->block2, 0, len, | 878 | buf_dblwr->block2, 0, len, |
281 | 844 | (void*) write_buf, NULL); | 879 | (void*) write_buf, NULL); |
282 | 845 | 880 | ||
283 | @@ -849,7 +884,7 @@ | |||
284 | 849 | srv_stats.dblwr_writes.inc(); | 884 | srv_stats.dblwr_writes.inc(); |
285 | 850 | 885 | ||
286 | 851 | /* Now flush the doublewrite buffer data to disk */ | 886 | /* Now flush the doublewrite buffer data to disk */ |
288 | 852 | fil_flush(TRX_SYS_SPACE); | 887 | fil_flush(doublewrite_space_id); |
289 | 853 | 888 | ||
290 | 854 | /* We know that the writes have been flushed to disk now | 889 | /* We know that the writes have been flushed to disk now |
291 | 855 | and in recovery we will find them in the doublewrite buffer | 890 | and in recovery we will find them in the doublewrite buffer |
292 | @@ -967,6 +1002,13 @@ | |||
293 | 967 | ulint zip_size; | 1002 | ulint zip_size; |
294 | 968 | ulint offset; | 1003 | ulint offset; |
295 | 969 | ulint i; | 1004 | ulint i; |
296 | 1005 | ulint doublewrite_space_id; | ||
297 | 1006 | |||
298 | 1007 | if (srv_doublewrite_file) { | ||
299 | 1008 | doublewrite_space_id = TRX_DOUBLEWRITE_SPACE; | ||
300 | 1009 | } else { | ||
301 | 1010 | doublewrite_space_id = TRX_SYS_SPACE; | ||
302 | 1011 | } | ||
303 | 970 | 1012 | ||
304 | 971 | ut_a(buf_page_in_file(bpage)); | 1013 | ut_a(buf_page_in_file(bpage)); |
305 | 972 | ut_a(srv_use_doublewrite_buf); | 1014 | ut_a(srv_use_doublewrite_buf); |
306 | @@ -1046,21 +1088,21 @@ | |||
307 | 1046 | memset(buf_dblwr->write_buf + UNIV_PAGE_SIZE * i | 1088 | memset(buf_dblwr->write_buf + UNIV_PAGE_SIZE * i |
308 | 1047 | + zip_size, 0, UNIV_PAGE_SIZE - zip_size); | 1089 | + zip_size, 0, UNIV_PAGE_SIZE - zip_size); |
309 | 1048 | 1090 | ||
311 | 1049 | fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0, | 1091 | fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0, |
312 | 1050 | offset, 0, UNIV_PAGE_SIZE, | 1092 | offset, 0, UNIV_PAGE_SIZE, |
313 | 1051 | (void*) (buf_dblwr->write_buf | 1093 | (void*) (buf_dblwr->write_buf |
314 | 1052 | + UNIV_PAGE_SIZE * i), NULL); | 1094 | + UNIV_PAGE_SIZE * i), NULL); |
315 | 1053 | } else { | 1095 | } else { |
316 | 1054 | /* It is a regular page. Write it directly to the | 1096 | /* It is a regular page. Write it directly to the |
317 | 1055 | doublewrite buffer */ | 1097 | doublewrite buffer */ |
319 | 1056 | fil_io(OS_FILE_WRITE, TRUE, TRX_SYS_SPACE, 0, | 1098 | fil_io(OS_FILE_WRITE, TRUE, doublewrite_space_id, 0, |
320 | 1057 | offset, 0, UNIV_PAGE_SIZE, | 1099 | offset, 0, UNIV_PAGE_SIZE, |
321 | 1058 | (void*) ((buf_block_t*) bpage)->frame, | 1100 | (void*) ((buf_block_t*) bpage)->frame, |
322 | 1059 | NULL); | 1101 | NULL); |
323 | 1060 | } | 1102 | } |
324 | 1061 | 1103 | ||
325 | 1062 | /* Now flush the doublewrite buffer data to disk */ | 1104 | /* Now flush the doublewrite buffer data to disk */ |
327 | 1063 | fil_flush(TRX_SYS_SPACE); | 1105 | fil_flush(doublewrite_space_id); |
328 | 1064 | 1106 | ||
329 | 1065 | /* We know that the write has been flushed to disk now | 1107 | /* We know that the write has been flushed to disk now |
330 | 1066 | and during recovery we will find it in the doublewrite buffer | 1108 | and during recovery we will find it in the doublewrite buffer |
331 | 1067 | 1109 | ||
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 | 133 | ignore_nonexistent_pages = mode & BUF_READ_IGNORE_NONEXISTENT_PAGES; | 133 | ignore_nonexistent_pages = mode & BUF_READ_IGNORE_NONEXISTENT_PAGES; |
337 | 134 | mode &= ~BUF_READ_IGNORE_NONEXISTENT_PAGES; | 134 | mode &= ~BUF_READ_IGNORE_NONEXISTENT_PAGES; |
338 | 135 | 135 | ||
340 | 136 | if (space == TRX_SYS_SPACE && buf_dblwr_page_inside(offset)) { | 136 | if ((space == TRX_SYS_SPACE |
341 | 137 | || (srv_doublewrite_file && space == TRX_DOUBLEWRITE_SPACE)) | ||
342 | 138 | && buf_dblwr_page_inside(offset)) { | ||
343 | 137 | ut_print_timestamp(stderr); | 139 | ut_print_timestamp(stderr); |
344 | 138 | fprintf(stderr, | 140 | fprintf(stderr, |
345 | 139 | " InnoDB: Warning: trying to read" | 141 | " InnoDB: Warning: trying to read" |
346 | 140 | 142 | ||
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 | 45 | #include "dict0priv.h" | 45 | #include "dict0priv.h" |
352 | 46 | #include "ha_prototypes.h" /* innobase_casedn_str() */ | 46 | #include "ha_prototypes.h" /* innobase_casedn_str() */ |
353 | 47 | #include "fts0priv.h" | 47 | #include "fts0priv.h" |
354 | 48 | #include "trx0sys.h" | ||
355 | 48 | 49 | ||
356 | 49 | /** Following are the InnoDB system tables. The positions in | 50 | /** Following are the InnoDB system tables. The positions in |
357 | 50 | this array are referenced by enum dict_system_table_id. */ | 51 | this array are referenced by enum dict_system_table_id. */ |
358 | @@ -1066,7 +1067,7 @@ | |||
359 | 1066 | discarded = !!(flags2 & DICT_TF2_DISCARDED); | 1067 | discarded = !!(flags2 & DICT_TF2_DISCARDED); |
360 | 1067 | } | 1068 | } |
361 | 1068 | 1069 | ||
363 | 1069 | if (space_id == 0) { | 1070 | if (trx_sys_sys_space(space_id)) { |
364 | 1070 | /* The system tablespace always exists. */ | 1071 | /* The system tablespace always exists. */ |
365 | 1071 | ut_ad(!discarded); | 1072 | ut_ad(!discarded); |
366 | 1072 | } else if (in_crash_recovery) { | 1073 | } else if (in_crash_recovery) { |
367 | @@ -2248,7 +2249,7 @@ | |||
368 | 2248 | btr_pcur_close(&pcur); | 2249 | btr_pcur_close(&pcur); |
369 | 2249 | mtr_commit(&mtr); | 2250 | mtr_commit(&mtr); |
370 | 2250 | 2251 | ||
372 | 2251 | if (table->space == 0) { | 2252 | if (trx_sys_sys_space(table->space)) { |
373 | 2252 | /* The system tablespace is always available. */ | 2253 | /* The system tablespace is always available. */ |
374 | 2253 | } else if (table->flags2 & DICT_TF2_DISCARDED) { | 2254 | } else if (table->flags2 & DICT_TF2_DISCARDED) { |
375 | 2254 | 2255 | ||
376 | 2255 | 2256 | ||
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 | 308 | static fil_system_t* fil_system = NULL; | 308 | static fil_system_t* fil_system = NULL; |
382 | 309 | 309 | ||
383 | 310 | /** Determine if (i) is a user tablespace id or not. */ | 310 | /** Determine if (i) is a user tablespace id or not. */ |
385 | 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)) |
386 | 312 | 312 | ||
387 | 313 | /** Determine if user has explicitly disabled fsync(). */ | 313 | /** Determine if user has explicitly disabled fsync(). */ |
388 | 314 | #ifndef __WIN__ | 314 | #ifndef __WIN__ |
389 | @@ -668,7 +668,7 @@ | |||
390 | 668 | 668 | ||
391 | 669 | UT_LIST_ADD_LAST(chain, space->chain, node); | 669 | UT_LIST_ADD_LAST(chain, space->chain, node); |
392 | 670 | 670 | ||
394 | 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) { |
395 | 672 | 672 | ||
396 | 673 | fil_system->max_assigned_id = id; | 673 | fil_system->max_assigned_id = id; |
397 | 674 | } | 674 | } |
398 | @@ -729,14 +729,14 @@ | |||
399 | 729 | size_bytes = os_file_get_size(node->handle); | 729 | size_bytes = os_file_get_size(node->handle); |
400 | 730 | ut_a(size_bytes != (os_offset_t) -1); | 730 | ut_a(size_bytes != (os_offset_t) -1); |
401 | 731 | #ifdef UNIV_HOTBACKUP | 731 | #ifdef UNIV_HOTBACKUP |
403 | 732 | if (space->id == 0) { | 732 | if (trx_sys_sys_space(space->id)) { |
404 | 733 | node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE); | 733 | node->size = (ulint) (size_bytes / UNIV_PAGE_SIZE); |
405 | 734 | os_file_close(node->handle); | 734 | os_file_close(node->handle); |
406 | 735 | goto add_size; | 735 | goto add_size; |
407 | 736 | } | 736 | } |
408 | 737 | #endif /* UNIV_HOTBACKUP */ | 737 | #endif /* UNIV_HOTBACKUP */ |
409 | 738 | ut_a(space->purpose != FIL_LOG); | 738 | ut_a(space->purpose != FIL_LOG); |
411 | 739 | ut_a(fil_is_user_tablespace_id(space->id)); | 739 | ut_a(!trx_sys_sys_space(space->id)); |
412 | 740 | 740 | ||
413 | 741 | if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) { | 741 | if (size_bytes < FIL_IBD_FILE_INITIAL_SIZE * UNIV_PAGE_SIZE) { |
414 | 742 | fprintf(stderr, | 742 | fprintf(stderr, |
415 | @@ -781,7 +781,7 @@ | |||
416 | 781 | } | 781 | } |
417 | 782 | 782 | ||
418 | 783 | if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED | 783 | if (UNIV_UNLIKELY(space_id == ULINT_UNDEFINED |
420 | 784 | || space_id == 0)) { | 784 | || trx_sys_sys_space(space_id))) { |
421 | 785 | fprintf(stderr, | 785 | fprintf(stderr, |
422 | 786 | "InnoDB: Error: tablespace id %lu" | 786 | "InnoDB: Error: tablespace id %lu" |
423 | 787 | " in file %s is not sensible\n", | 787 | " in file %s is not sensible\n", |
424 | @@ -864,7 +864,6 @@ | |||
425 | 864 | fil_n_file_opened++; | 864 | fil_n_file_opened++; |
426 | 865 | 865 | ||
427 | 866 | if (fil_space_belongs_in_lru(space)) { | 866 | if (fil_space_belongs_in_lru(space)) { |
428 | 867 | |||
429 | 868 | /* Put the node to the LRU list */ | 867 | /* Put the node to the LRU list */ |
430 | 869 | UT_LIST_ADD_FIRST(LRU, system->LRU, node); | 868 | UT_LIST_ADD_FIRST(LRU, system->LRU, node); |
431 | 870 | } | 869 | } |
432 | @@ -903,7 +902,6 @@ | |||
433 | 903 | fil_n_file_opened--; | 902 | fil_n_file_opened--; |
434 | 904 | 903 | ||
435 | 905 | if (fil_space_belongs_in_lru(node->space)) { | 904 | if (fil_space_belongs_in_lru(node->space)) { |
436 | 906 | |||
437 | 907 | ut_a(UT_LIST_GET_LEN(system->LRU) > 0); | 905 | ut_a(UT_LIST_GET_LEN(system->LRU) > 0); |
438 | 908 | 906 | ||
439 | 909 | /* The node is in the LRU list, remove it */ | 907 | /* The node is in the LRU list, remove it */ |
440 | @@ -999,7 +997,7 @@ | |||
441 | 999 | retry: | 997 | retry: |
442 | 1000 | mutex_enter(&fil_system->mutex); | 998 | mutex_enter(&fil_system->mutex); |
443 | 1001 | 999 | ||
445 | 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) { |
446 | 1003 | /* We keep log files and system tablespace files always open; | 1001 | /* We keep log files and system tablespace files always open; |
447 | 1004 | this is important in preventing deadlocks in this module, as | 1002 | this is important in preventing deadlocks in this module, as |
448 | 1005 | a page read completion often performs another read from the | 1003 | a page read completion often performs another read from the |
449 | @@ -1276,9 +1274,9 @@ | |||
450 | 1276 | space->tablespace_version = fil_system->tablespace_version; | 1274 | space->tablespace_version = fil_system->tablespace_version; |
451 | 1277 | space->mark = FALSE; | 1275 | space->mark = FALSE; |
452 | 1278 | 1276 | ||
456 | 1279 | if (purpose == FIL_TABLESPACE && !recv_recovery_on | 1277 | if (UNIV_LIKELY(purpose == FIL_TABLESPACE && !recv_recovery_on) |
457 | 1280 | && id > fil_system->max_assigned_id) { | 1278 | && UNIV_UNLIKELY(id < SRV_EXTRA_SYS_SPACE_FIRST_ID) |
458 | 1281 | 1279 | && UNIV_UNLIKELY(id > fil_system->max_assigned_id)) { | |
459 | 1282 | if (!fil_system->space_id_reuse_warned) { | 1280 | if (!fil_system->space_id_reuse_warned) { |
460 | 1283 | fil_system->space_id_reuse_warned = TRUE; | 1281 | fil_system->space_id_reuse_warned = TRUE; |
461 | 1284 | 1282 | ||
462 | @@ -1350,7 +1348,7 @@ | |||
463 | 1350 | (ulong) SRV_LOG_SPACE_FIRST_ID); | 1348 | (ulong) SRV_LOG_SPACE_FIRST_ID); |
464 | 1351 | } | 1349 | } |
465 | 1352 | 1350 | ||
467 | 1353 | success = (id < SRV_LOG_SPACE_FIRST_ID); | 1351 | success = (id < SRV_EXTRA_SYS_SPACE_FIRST_ID); |
468 | 1354 | 1352 | ||
469 | 1355 | if (success) { | 1353 | if (success) { |
470 | 1356 | *space_id = fil_system->max_assigned_id = id; | 1354 | *space_id = fil_system->max_assigned_id = id; |
471 | @@ -1773,6 +1771,10 @@ | |||
472 | 1773 | ut_error; | 1771 | ut_error; |
473 | 1774 | } | 1772 | } |
474 | 1775 | 1773 | ||
475 | 1774 | if (max_id >= SRV_EXTRA_SYS_SPACE_FIRST_ID) { | ||
476 | 1775 | return; | ||
477 | 1776 | } | ||
478 | 1777 | |||
479 | 1776 | mutex_enter(&fil_system->mutex); | 1778 | mutex_enter(&fil_system->mutex); |
480 | 1777 | 1779 | ||
481 | 1778 | if (fil_system->max_assigned_id < max_id) { | 1780 | if (fil_system->max_assigned_id < max_id) { |
482 | @@ -4067,7 +4069,7 @@ | |||
483 | 4067 | } | 4069 | } |
484 | 4068 | 4070 | ||
485 | 4069 | #ifdef UNIV_HOTBACKUP | 4071 | #ifdef UNIV_HOTBACKUP |
487 | 4070 | if (fsp->id == ULINT_UNDEFINED || fsp->id == 0) { | 4072 | if (fsp->id == ULINT_UNDEFINED || trx_sys_sys_space(fsp->id)) { |
488 | 4071 | char* new_path; | 4073 | char* new_path; |
489 | 4072 | 4074 | ||
490 | 4073 | fprintf(stderr, | 4075 | fprintf(stderr, |
491 | @@ -4967,7 +4969,6 @@ | |||
492 | 4967 | } | 4969 | } |
493 | 4968 | 4970 | ||
494 | 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)) { |
495 | 4970 | |||
496 | 4971 | /* The node must be put back to the LRU list */ | 4972 | /* The node must be put back to the LRU list */ |
497 | 4972 | UT_LIST_ADD_FIRST(LRU, system->LRU, node); | 4973 | UT_LIST_ADD_FIRST(LRU, system->LRU, node); |
498 | 4973 | } | 4974 | } |
499 | 4974 | 4975 | ||
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 | 49 | #endif /* UNIV_HOTBACKUP */ | 49 | #endif /* UNIV_HOTBACKUP */ |
505 | 50 | #include "dict0mem.h" | 50 | #include "dict0mem.h" |
506 | 51 | #include "srv0start.h" | 51 | #include "srv0start.h" |
508 | 52 | 52 | #include "trx0sys.h" | |
509 | 53 | 53 | ||
510 | 54 | #ifndef UNIV_HOTBACKUP | 54 | #ifndef UNIV_HOTBACKUP |
511 | 55 | /** Flag to indicate if we have printed the tablespace full error. */ | 55 | /** Flag to indicate if we have printed the tablespace full error. */ |
512 | @@ -832,10 +832,10 @@ | |||
513 | 832 | flst_init(header + FSP_SEG_INODES_FREE, mtr); | 832 | flst_init(header + FSP_SEG_INODES_FREE, mtr); |
514 | 833 | 833 | ||
515 | 834 | mlog_write_ull(header + FSP_SEG_ID, 1, mtr); | 834 | mlog_write_ull(header + FSP_SEG_ID, 1, mtr); |
517 | 835 | if (space == 0) { | 835 | if (space == TRX_SYS_SPACE || space == TRX_DOUBLEWRITE_SPACE) { |
518 | 836 | fsp_fill_free_list(FALSE, space, header, mtr); | 836 | fsp_fill_free_list(FALSE, space, header, mtr); |
519 | 837 | btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, | 837 | btr_create(DICT_CLUSTERED | DICT_UNIVERSAL | DICT_IBUF, |
521 | 838 | 0, 0, DICT_IBUF_ID_MIN + space, | 838 | space, 0, DICT_IBUF_ID_MIN + space, |
522 | 839 | dict_ind_redundant, mtr); | 839 | dict_ind_redundant, mtr); |
523 | 840 | } else { | 840 | } else { |
524 | 841 | fsp_fill_free_list(TRUE, space, header, mtr); | 841 | fsp_fill_free_list(TRUE, space, header, mtr); |
525 | 842 | 842 | ||
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 | 159 | static char* innobase_disable_monitor_counter = NULL; | 159 | static char* innobase_disable_monitor_counter = NULL; |
531 | 160 | static char* innobase_reset_monitor_counter = NULL; | 160 | static char* innobase_reset_monitor_counter = NULL; |
532 | 161 | static char* innobase_reset_all_monitor_counter = NULL; | 161 | static char* innobase_reset_all_monitor_counter = NULL; |
533 | 162 | static char* innobase_doublewrite_file = NULL; | ||
534 | 162 | 163 | ||
535 | 163 | /* The highest file format being used in the database. The value can be | 164 | /* The highest file format being used in the database. The value can be |
536 | 164 | set by user, however, it will be adjusted to the newer file format if | 165 | set by user, however, it will be adjusted to the newer file format if |
537 | @@ -2920,6 +2921,8 @@ | |||
538 | 2920 | goto error; | 2921 | goto error; |
539 | 2921 | } | 2922 | } |
540 | 2922 | 2923 | ||
541 | 2924 | srv_doublewrite_file = innobase_doublewrite_file; | ||
542 | 2925 | |||
543 | 2923 | /* -------------- All log files ---------------------------*/ | 2926 | /* -------------- All log files ---------------------------*/ |
544 | 2924 | 2927 | ||
545 | 2925 | /* The default dir for log files is the datadir of MySQL */ | 2928 | /* The default dir for log files is the datadir of MySQL */ |
546 | @@ -15799,6 +15802,11 @@ | |||
547 | 15799 | 1, /* Minimum value */ | 15802 | 1, /* Minimum value */ |
548 | 15800 | TRX_SYS_N_RSEGS, 0); /* Maximum value */ | 15803 | TRX_SYS_N_RSEGS, 0); /* Maximum value */ |
549 | 15801 | 15804 | ||
550 | 15805 | static MYSQL_SYSVAR_STR(doublewrite_file, innobase_doublewrite_file, | ||
551 | 15806 | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, | ||
552 | 15807 | "Path to special datafile for doublewrite buffer. (default is "": not used) ### ONLY FOR EXPERTS!!! ###", | ||
553 | 15808 | NULL, NULL, NULL); | ||
554 | 15809 | |||
555 | 15802 | static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode, | 15810 | static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode, |
556 | 15803 | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, | 15811 | PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, |
557 | 15804 | "The AUTOINC lock modes supported by InnoDB: " | 15812 | "The AUTOINC lock modes supported by InnoDB: " |
558 | @@ -15980,6 +15988,7 @@ | |||
559 | 15980 | MYSQL_SYSVAR(concurrency_tickets), | 15988 | MYSQL_SYSVAR(concurrency_tickets), |
560 | 15981 | MYSQL_SYSVAR(compression_level), | 15989 | MYSQL_SYSVAR(compression_level), |
561 | 15982 | MYSQL_SYSVAR(data_file_path), | 15990 | MYSQL_SYSVAR(data_file_path), |
562 | 15991 | MYSQL_SYSVAR(doublewrite_file), | ||
563 | 15983 | MYSQL_SYSVAR(data_home_dir), | 15992 | MYSQL_SYSVAR(data_home_dir), |
564 | 15984 | MYSQL_SYSVAR(doublewrite), | 15993 | MYSQL_SYSVAR(doublewrite), |
565 | 15985 | MYSQL_SYSVAR(api_enable_binlog), | 15994 | MYSQL_SYSVAR(api_enable_binlog), |
566 | 15986 | 15995 | ||
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 | 28 | #include "buf0buf.h" | 28 | #include "buf0buf.h" |
572 | 29 | #include "buf0dblwr.h" | 29 | #include "buf0dblwr.h" |
573 | 30 | #include "fsp0types.h" | 30 | #include "fsp0types.h" |
574 | 31 | #include "srv0srv.h" | ||
575 | 31 | #include "trx0sys.h" | 32 | #include "trx0sys.h" |
576 | 32 | |||
577 | 33 | /********************************************************//** | 33 | /********************************************************//** |
578 | 34 | Opens a buffer to mlog. It must be closed with mlog_close. | 34 | Opens a buffer to mlog. It must be closed with mlog_close. |
579 | 35 | @return buffer, NULL if log mode MTR_LOG_NONE */ | 35 | @return buffer, NULL if log mode MTR_LOG_NONE */ |
580 | @@ -202,7 +202,8 @@ | |||
581 | 202 | the doublewrite buffer is located in pages | 202 | the doublewrite buffer is located in pages |
582 | 203 | FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the | 203 | FSP_EXTENT_SIZE, ..., 3 * FSP_EXTENT_SIZE - 1 in the |
583 | 204 | system tablespace */ | 204 | system tablespace */ |
585 | 205 | if (space == TRX_SYS_SPACE | 205 | if ((space == TRX_SYS_SPACE |
586 | 206 | || (srv_doublewrite_file && space == TRX_DOUBLEWRITE_SPACE)) | ||
587 | 206 | && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) { | 207 | && offset >= FSP_EXTENT_SIZE && offset < 3 * FSP_EXTENT_SIZE) { |
588 | 207 | if (buf_dblwr_being_created) { | 208 | if (buf_dblwr_being_created) { |
589 | 208 | /* Do nothing: we only come to this branch in an | 209 | /* Do nothing: we only come to this branch in an |
590 | 209 | 210 | ||
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 | 235 | extern ulint* srv_data_file_sizes; | 235 | extern ulint* srv_data_file_sizes; |
596 | 236 | extern ulint* srv_data_file_is_raw_partition; | 236 | extern ulint* srv_data_file_is_raw_partition; |
597 | 237 | 237 | ||
598 | 238 | extern char* srv_doublewrite_file; | ||
599 | 239 | |||
600 | 238 | extern ibool srv_auto_extend_last_data_file; | 240 | extern ibool srv_auto_extend_last_data_file; |
601 | 239 | extern ulint srv_last_file_size_max; | 241 | extern ulint srv_last_file_size_max; |
602 | 240 | extern char** srv_log_group_home_dirs; | 242 | extern char** srv_log_group_home_dirs; |
603 | 241 | 243 | ||
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 | 173 | /** Log 'spaces' have id's >= this */ | 173 | /** Log 'spaces' have id's >= this */ |
609 | 174 | #define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0UL | 174 | #define SRV_LOG_SPACE_FIRST_ID 0xFFFFFFF0UL |
610 | 175 | 175 | ||
611 | 176 | /** reserved for extra system tables */ | ||
612 | 177 | #define SRV_EXTRA_SYS_SPACE_FIRST_ID 0xFFFFFFE0UL | ||
613 | 178 | |||
614 | 176 | #endif | 179 | #endif |
615 | 177 | 180 | ||
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 | 78 | /*=============*/ | 78 | /*=============*/ |
621 | 79 | ulint space, /*!< in: space */ | 79 | ulint space, /*!< in: space */ |
622 | 80 | ulint page_no);/*!< in: page number */ | 80 | ulint page_no);/*!< in: page number */ |
623 | 81 | /***************************************************************//** | ||
624 | 82 | Checks if a space is the system tablespaces. | ||
625 | 83 | @return TRUE if system tablespace */ | ||
626 | 84 | UNIV_INLINE | ||
627 | 85 | ibool | ||
628 | 86 | trx_sys_sys_space( | ||
629 | 87 | /*==============*/ | ||
630 | 88 | ulint space); /*!< in: space */ | ||
631 | 89 | /***************************************************************//** | ||
632 | 90 | Checks if a space is the doublewrite tablespace. | ||
633 | 91 | @return TRUE if doublewrite tablespace */ | ||
634 | 92 | UNIV_INLINE | ||
635 | 93 | ibool | ||
636 | 94 | trx_sys_doublewrite_space( | ||
637 | 95 | /*======================*/ | ||
638 | 96 | ulint space); /*!< in: space */ | ||
639 | 81 | /*****************************************************************//** | 97 | /*****************************************************************//** |
640 | 82 | Creates and initializes the central memory structures for the transaction | 98 | Creates and initializes the central memory structures for the transaction |
641 | 83 | system. This is called when the database is started. | 99 | system. This is called when the database is started. |
642 | @@ -463,6 +479,8 @@ | |||
643 | 463 | 479 | ||
644 | 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 */ |
645 | 465 | #define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */ | 481 | #define TRX_SYS_SPACE 0 /* the SYSTEM tablespace */ |
646 | 482 | #define TRX_DOUBLEWRITE_SPACE 0xFFFFFFE0UL /* the doublewrite buffer tablespace if used */ | ||
647 | 483 | #define TRX_SYS_SPACE_MAX 9 /* reserved max space id for system tablespaces */ | ||
648 | 466 | #include "fsp0fsp.h" | 484 | #include "fsp0fsp.h" |
649 | 467 | #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO | 485 | #define TRX_SYS_PAGE_NO FSP_TRX_SYS_PAGE_NO |
650 | 468 | 486 | ||
651 | @@ -660,3 +678,9 @@ | |||
652 | 660 | #endif | 678 | #endif |
653 | 661 | 679 | ||
654 | 662 | #endif | 680 | #endif |
655 | 681 | |||
656 | 682 | UNIV_INTERN | ||
657 | 683 | void | ||
658 | 684 | trx_sys_dummy_create( | ||
659 | 685 | /*=================*/ | ||
660 | 686 | ulint space); | ||
661 | 663 | 687 | ||
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 | 25 | 25 | ||
667 | 26 | #include "trx0trx.h" | 26 | #include "trx0trx.h" |
668 | 27 | #include "data0type.h" | 27 | #include "data0type.h" |
669 | 28 | #include "srv0srv.h" | ||
670 | 28 | #ifndef UNIV_HOTBACKUP | 29 | #ifndef UNIV_HOTBACKUP |
671 | 29 | # include "srv0srv.h" | 30 | # include "srv0srv.h" |
672 | 30 | # include "mtr0log.h" | 31 | # include "mtr0log.h" |
673 | @@ -71,6 +72,40 @@ | |||
674 | 71 | } | 72 | } |
675 | 72 | 73 | ||
676 | 73 | /***************************************************************//** | 74 | /***************************************************************//** |
677 | 75 | Checks if a space is the system tablespaces. | ||
678 | 76 | @return TRUE if system tablespace */ | ||
679 | 77 | UNIV_INLINE | ||
680 | 78 | ibool | ||
681 | 79 | trx_sys_sys_space( | ||
682 | 80 | /*==============*/ | ||
683 | 81 | ulint space) /*!< in: space */ | ||
684 | 82 | { | ||
685 | 83 | if (srv_doublewrite_file) { | ||
686 | 84 | /* several spaces are reserved */ | ||
687 | 85 | return((ibool)(space == TRX_SYS_SPACE || space == TRX_DOUBLEWRITE_SPACE)); | ||
688 | 86 | } else { | ||
689 | 87 | return((ibool)(space == TRX_SYS_SPACE)); | ||
690 | 88 | } | ||
691 | 89 | } | ||
692 | 90 | |||
693 | 91 | /***************************************************************//** | ||
694 | 92 | Checks if a space is the doublewrite tablespace. | ||
695 | 93 | @return TRUE if doublewrite tablespace */ | ||
696 | 94 | UNIV_INLINE | ||
697 | 95 | ibool | ||
698 | 96 | trx_sys_doublewrite_space( | ||
699 | 97 | /*======================*/ | ||
700 | 98 | ulint space) /*!< in: space */ | ||
701 | 99 | { | ||
702 | 100 | if (srv_doublewrite_file) { | ||
703 | 101 | /* doublewrite buffer is separated */ | ||
704 | 102 | return((ibool)(space == TRX_DOUBLEWRITE_SPACE)); | ||
705 | 103 | } else { | ||
706 | 104 | return((ibool)(space == TRX_SYS_SPACE)); | ||
707 | 105 | } | ||
708 | 106 | } | ||
709 | 107 | |||
710 | 108 | /***************************************************************//** | ||
711 | 74 | Gets the pointer in the nth slot of the rseg array. | 109 | Gets the pointer in the nth slot of the rseg array. |
712 | 75 | @return pointer to rseg object, NULL if slot not in use */ | 110 | @return pointer to rseg object, NULL if slot not in use */ |
713 | 76 | UNIV_INLINE | 111 | UNIV_INLINE |
714 | 77 | 112 | ||
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 | 4108 | a temp table or if the tablesace has been discarded. */ | 4108 | a temp table or if the tablesace has been discarded. */ |
720 | 4109 | print_msg = !(is_temp || ibd_file_missing); | 4109 | print_msg = !(is_temp || ibd_file_missing); |
721 | 4110 | 4110 | ||
723 | 4111 | if (err == DB_SUCCESS && space_id > TRX_SYS_SPACE) { | 4111 | if (err == DB_SUCCESS && !trx_sys_sys_space(space_id)) { |
724 | 4112 | if (!is_temp | 4112 | if (!is_temp |
725 | 4113 | && !fil_space_for_table_exists_in_mem( | 4113 | && !fil_space_for_table_exists_in_mem( |
726 | 4114 | space_id, tablename, FALSE, print_msg)) { | 4114 | space_id, tablename, FALSE, print_msg)) { |
727 | 4115 | 4115 | ||
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 | 161 | /* size in database pages */ | 161 | /* size in database pages */ |
733 | 162 | UNIV_INTERN ulint* srv_data_file_sizes = NULL; | 162 | UNIV_INTERN ulint* srv_data_file_sizes = NULL; |
734 | 163 | 163 | ||
735 | 164 | UNIV_INTERN char* srv_doublewrite_file = NULL; | ||
736 | 165 | |||
737 | 164 | /* if TRUE, then we auto-extend the last data file */ | 166 | /* if TRUE, then we auto-extend the last data file */ |
738 | 165 | UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE; | 167 | UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE; |
739 | 166 | /* if != 0, this tells the max size auto-extending may increase the | 168 | /* if != 0, this tells the max size auto-extending may increase the |
740 | 167 | 169 | ||
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 | 761 | /*======================*/ | 761 | /*======================*/ |
746 | 762 | ibool* create_new_db, /*!< out: TRUE if new database should be | 762 | ibool* create_new_db, /*!< out: TRUE if new database should be |
747 | 763 | created */ | 763 | created */ |
748 | 764 | ibool* create_new_doublewrite_file, | ||
749 | 764 | #ifdef UNIV_LOG_ARCHIVE | 765 | #ifdef UNIV_LOG_ARCHIVE |
750 | 765 | ulint* min_arch_log_no,/*!< out: min of archived log | 766 | ulint* min_arch_log_no,/*!< out: min of archived log |
751 | 766 | numbers in data files */ | 767 | numbers in data files */ |
752 | @@ -796,6 +797,7 @@ | |||
753 | 796 | *sum_of_new_sizes = 0; | 797 | *sum_of_new_sizes = 0; |
754 | 797 | 798 | ||
755 | 798 | *create_new_db = FALSE; | 799 | *create_new_db = FALSE; |
756 | 800 | *create_new_doublewrite_file = FALSE; | ||
757 | 799 | 801 | ||
758 | 800 | srv_normalize_path_for_win(srv_data_home); | 802 | srv_normalize_path_for_win(srv_data_home); |
759 | 801 | 803 | ||
760 | @@ -1066,6 +1068,139 @@ | |||
761 | 1066 | srv_data_file_is_raw_partition[i] != 0); | 1068 | srv_data_file_is_raw_partition[i] != 0); |
762 | 1067 | } | 1069 | } |
763 | 1068 | 1070 | ||
764 | 1071 | /* special file for doublewrite buffer */ | ||
765 | 1072 | if (srv_doublewrite_file) | ||
766 | 1073 | { | ||
767 | 1074 | srv_normalize_path_for_win(srv_doublewrite_file); | ||
768 | 1075 | |||
769 | 1076 | fprintf(stderr, | ||
770 | 1077 | "InnoDB: Note: The innodb_doublewrite_file option has been specified.\n" | ||
771 | 1078 | "InnoDB: This option is for experts only. Don't use it unless you understand WELL what it is.\n" | ||
772 | 1079 | "InnoDB: ### Don't specify a file older than the last checkpoint. ###\n" | ||
773 | 1080 | "InnoDB: Otherwise, the older doublewrite buffer will break your data during recovery!\n"); | ||
774 | 1081 | |||
775 | 1082 | strcpy(name, srv_doublewrite_file); | ||
776 | 1083 | |||
777 | 1084 | /* First we try to create the file: if it already | ||
778 | 1085 | exists, ret will get value FALSE */ | ||
779 | 1086 | |||
780 | 1087 | files[i] = os_file_create(innodb_file_data_key, name, OS_FILE_CREATE, | ||
781 | 1088 | OS_FILE_NORMAL, | ||
782 | 1089 | OS_DATA_FILE, &ret); | ||
783 | 1090 | |||
784 | 1091 | if (ret == FALSE && os_file_get_last_error(FALSE) | ||
785 | 1092 | != OS_FILE_ALREADY_EXISTS | ||
786 | 1093 | #ifdef UNIV_AIX | ||
787 | 1094 | /* AIX 5.1 after security patch ML7 may have | ||
788 | 1095 | errno set to 0 here, which causes our function | ||
789 | 1096 | to return 100; work around that AIX problem */ | ||
790 | 1097 | && os_file_get_last_error(FALSE) != 100 | ||
791 | 1098 | #endif | ||
792 | 1099 | ) { | ||
793 | 1100 | fprintf(stderr, | ||
794 | 1101 | "InnoDB: Error in creating" | ||
795 | 1102 | " or opening %s\n", | ||
796 | 1103 | name); | ||
797 | 1104 | |||
798 | 1105 | return(DB_ERROR); | ||
799 | 1106 | } | ||
800 | 1107 | |||
801 | 1108 | if (ret == FALSE) { | ||
802 | 1109 | /* We open the data file */ | ||
803 | 1110 | |||
804 | 1111 | files[i] = os_file_create(innodb_file_data_key, | ||
805 | 1112 | name, OS_FILE_OPEN, OS_FILE_NORMAL, | ||
806 | 1113 | OS_DATA_FILE, &ret); | ||
807 | 1114 | |||
808 | 1115 | if (!ret) { | ||
809 | 1116 | fprintf(stderr, | ||
810 | 1117 | "InnoDB: Error in opening %s\n", name); | ||
811 | 1118 | os_file_get_last_error(TRUE); | ||
812 | 1119 | |||
813 | 1120 | return(DB_ERROR); | ||
814 | 1121 | } | ||
815 | 1122 | |||
816 | 1123 | size = os_file_get_size(files[i]); | ||
817 | 1124 | /* Round size downward to megabytes */ | ||
818 | 1125 | |||
819 | 1126 | rounded_size_pages = (ulint) | ||
820 | 1127 | (size >> UNIV_PAGE_SIZE_SHIFT); | ||
821 | 1128 | |||
822 | 1129 | if (rounded_size_pages != TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9) { | ||
823 | 1130 | |||
824 | 1131 | fprintf(stderr, | ||
825 | 1132 | "InnoDB: Warning: doublewrite buffer file %s" | ||
826 | 1133 | " is of a different size\n" | ||
827 | 1134 | "InnoDB: %lu pages" | ||
828 | 1135 | " (rounded down to MB)\n" | ||
829 | 1136 | "InnoDB: than intended size" | ||
830 | 1137 | " %lu pages...\n", | ||
831 | 1138 | name, | ||
832 | 1139 | (ulong) rounded_size_pages, | ||
833 | 1140 | (ulong) TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9); | ||
834 | 1141 | } | ||
835 | 1142 | |||
836 | 1143 | fil_read_first_page(files[i], one_opened, &flags, | ||
837 | 1144 | &space, | ||
838 | 1145 | #ifdef UNIV_LOG_ARCHIVE | ||
839 | 1146 | min_arch_log_no, max_arch_log_no, | ||
840 | 1147 | #endif /* UNIV_LOG_ARCHIVE */ | ||
841 | 1148 | min_flushed_lsn, max_flushed_lsn); | ||
842 | 1149 | one_opened = TRUE; | ||
843 | 1150 | } else { | ||
844 | 1151 | /* We created the data file and now write it full of | ||
845 | 1152 | zeros */ | ||
846 | 1153 | |||
847 | 1154 | *create_new_doublewrite_file = TRUE; | ||
848 | 1155 | |||
849 | 1156 | ut_print_timestamp(stderr); | ||
850 | 1157 | fprintf(stderr, | ||
851 | 1158 | " InnoDB: Doublewrite buffer file %s did not" | ||
852 | 1159 | " exist. It will be be created.\n", | ||
853 | 1160 | name); | ||
854 | 1161 | |||
855 | 1162 | if (*create_new_db == FALSE) { | ||
856 | 1163 | fprintf(stderr, | ||
857 | 1164 | "InnoDB: Notice: Previous version's ibdata files may cause crash.\n" | ||
858 | 1165 | " If you use that, please use the ibdata files of this version.\n"); | ||
859 | 1166 | } | ||
860 | 1167 | |||
861 | 1168 | ut_print_timestamp(stderr); | ||
862 | 1169 | fprintf(stderr, | ||
863 | 1170 | " InnoDB: Setting file %s size to %lu MB\n", | ||
864 | 1171 | name, | ||
865 | 1172 | (ulong) ((TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9) | ||
866 | 1173 | >> (20 - UNIV_PAGE_SIZE_SHIFT))); | ||
867 | 1174 | |||
868 | 1175 | fprintf(stderr, | ||
869 | 1176 | "InnoDB: Database physically writes the" | ||
870 | 1177 | " file full: wait...\n"); | ||
871 | 1178 | |||
872 | 1179 | ret = os_file_set_size( | ||
873 | 1180 | name, files[i], | ||
874 | 1181 | (TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9) << UNIV_PAGE_SIZE_SHIFT); | ||
875 | 1182 | |||
876 | 1183 | if (!ret) { | ||
877 | 1184 | fprintf(stderr, | ||
878 | 1185 | "InnoDB: Error in creating %s:" | ||
879 | 1186 | " probably out of disk space\n", name); | ||
880 | 1187 | |||
881 | 1188 | return(DB_ERROR); | ||
882 | 1189 | } | ||
883 | 1190 | } | ||
884 | 1191 | |||
885 | 1192 | ret = os_file_close(files[i]); | ||
886 | 1193 | ut_a(ret); | ||
887 | 1194 | |||
888 | 1195 | fil_space_create(name, TRX_DOUBLEWRITE_SPACE, 0, FIL_TABLESPACE); | ||
889 | 1196 | |||
890 | 1197 | ut_a(fil_validate()); | ||
891 | 1198 | |||
892 | 1199 | fil_node_create(name, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, TRX_DOUBLEWRITE_SPACE, FALSE); | ||
893 | 1200 | |||
894 | 1201 | i++; | ||
895 | 1202 | } | ||
896 | 1203 | |||
897 | 1069 | return(DB_SUCCESS); | 1204 | return(DB_SUCCESS); |
898 | 1070 | } | 1205 | } |
899 | 1071 | 1206 | ||
900 | @@ -1448,6 +1583,7 @@ | |||
901 | 1448 | /*====================================*/ | 1583 | /*====================================*/ |
902 | 1449 | { | 1584 | { |
903 | 1450 | ibool create_new_db; | 1585 | ibool create_new_db; |
904 | 1586 | ibool create_new_doublewrite_file; | ||
905 | 1451 | ibool log_file_created; | 1587 | ibool log_file_created; |
906 | 1452 | ibool log_created = FALSE; | 1588 | ibool log_created = FALSE; |
907 | 1453 | ibool log_opened = FALSE; | 1589 | ibool log_opened = FALSE; |
908 | @@ -1940,6 +2076,7 @@ | |||
909 | 1940 | } | 2076 | } |
910 | 1941 | 2077 | ||
911 | 1942 | err = open_or_create_data_files(&create_new_db, | 2078 | err = open_or_create_data_files(&create_new_db, |
912 | 2079 | &create_new_doublewrite_file, | ||
913 | 1943 | #ifdef UNIV_LOG_ARCHIVE | 2080 | #ifdef UNIV_LOG_ARCHIVE |
914 | 1944 | &min_arch_log_no, &max_arch_log_no, | 2081 | &min_arch_log_no, &max_arch_log_no, |
915 | 1945 | #endif /* UNIV_LOG_ARCHIVE */ | 2082 | #endif /* UNIV_LOG_ARCHIVE */ |
916 | @@ -2112,6 +2249,14 @@ | |||
917 | 2112 | 2249 | ||
918 | 2113 | trx_purge_sys_create(srv_n_purge_threads, ib_bh); | 2250 | trx_purge_sys_create(srv_n_purge_threads, ib_bh); |
919 | 2114 | 2251 | ||
920 | 2252 | if (create_new_doublewrite_file) { | ||
921 | 2253 | mtr_start(&mtr); | ||
922 | 2254 | fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr); | ||
923 | 2255 | mtr_commit(&mtr); | ||
924 | 2256 | |||
925 | 2257 | trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE); | ||
926 | 2258 | } | ||
927 | 2259 | |||
928 | 2115 | dict_create(); | 2260 | dict_create(); |
929 | 2116 | 2261 | ||
930 | 2117 | srv_startup_is_before_trx_rollback_phase = FALSE; | 2262 | srv_startup_is_before_trx_rollback_phase = FALSE; |
931 | @@ -2146,6 +2291,13 @@ | |||
932 | 2146 | recv_recovery_from_archive_finish(); | 2291 | recv_recovery_from_archive_finish(); |
933 | 2147 | #endif /* UNIV_LOG_ARCHIVE */ | 2292 | #endif /* UNIV_LOG_ARCHIVE */ |
934 | 2148 | } else { | 2293 | } else { |
935 | 2294 | char* save_srv_doublewrite_file = NULL; | ||
936 | 2295 | |||
937 | 2296 | if (create_new_doublewrite_file) { | ||
938 | 2297 | /* doublewrite_file cannot be used for recovery yet. */ | ||
939 | 2298 | save_srv_doublewrite_file = srv_doublewrite_file; | ||
940 | 2299 | srv_doublewrite_file = NULL; | ||
941 | 2300 | } | ||
942 | 2149 | 2301 | ||
943 | 2150 | /* Check if we support the max format that is stamped | 2302 | /* Check if we support the max format that is stamped |
944 | 2151 | on the system tablespace. | 2303 | on the system tablespace. |
945 | @@ -2235,6 +2387,17 @@ | |||
946 | 2235 | we have finished the recovery process so that the | 2387 | we have finished the recovery process so that the |
947 | 2236 | image of TRX_SYS_PAGE_NO is not stale. */ | 2388 | image of TRX_SYS_PAGE_NO is not stale. */ |
948 | 2237 | trx_sys_file_format_tag_init(); | 2389 | trx_sys_file_format_tag_init(); |
949 | 2390 | |||
950 | 2391 | if (create_new_doublewrite_file) { | ||
951 | 2392 | /* restore the value */ | ||
952 | 2393 | srv_doublewrite_file = save_srv_doublewrite_file; | ||
953 | 2394 | |||
954 | 2395 | mtr_start(&mtr); | ||
955 | 2396 | fsp_header_init(TRX_DOUBLEWRITE_SPACE, TRX_SYS_DOUBLEWRITE_BLOCK_SIZE * 9, &mtr); | ||
956 | 2397 | mtr_commit(&mtr); | ||
957 | 2398 | |||
958 | 2399 | trx_sys_dummy_create(TRX_DOUBLEWRITE_SPACE); | ||
959 | 2400 | } | ||
960 | 2238 | } | 2401 | } |
961 | 2239 | 2402 | ||
962 | 2240 | if (!create_new_db && sum_of_new_sizes > 0) { | 2403 | if (!create_new_db && sum_of_new_sizes > 0) { |
963 | 2241 | 2404 | ||
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 | 385 | void | 385 | void |
969 | 386 | trx_sysf_create( | 386 | trx_sysf_create( |
970 | 387 | /*============*/ | 387 | /*============*/ |
972 | 388 | mtr_t* mtr) /*!< in: mtr */ | 388 | mtr_t* mtr, /*!< in: mtr */ |
973 | 389 | ulint space_id) | ||
974 | 389 | { | 390 | { |
975 | 390 | trx_sysf_t* sys_header; | 391 | trx_sysf_t* sys_header; |
976 | 391 | ulint slot_no; | 392 | ulint slot_no; |
977 | @@ -401,10 +402,10 @@ | |||
978 | 401 | then enter the kernel: we must do it in this order to conform | 402 | then enter the kernel: we must do it in this order to conform |
979 | 402 | to the latching order rules. */ | 403 | to the latching order rules. */ |
980 | 403 | 404 | ||
982 | 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); |
983 | 405 | 406 | ||
984 | 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 */ |
986 | 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, |
987 | 408 | mtr); | 409 | mtr); |
988 | 409 | buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER); | 410 | buf_block_dbg_add_level(block, SYNC_TRX_SYS_HEADER); |
989 | 410 | 411 | ||
990 | @@ -422,6 +423,12 @@ | |||
991 | 422 | mlog_write_ulint(page + TRX_SYS_DOUBLEWRITE | 423 | mlog_write_ulint(page + TRX_SYS_DOUBLEWRITE |
992 | 423 | + TRX_SYS_DOUBLEWRITE_MAGIC, 0, MLOG_4BYTES, mtr); | 424 | + TRX_SYS_DOUBLEWRITE_MAGIC, 0, MLOG_4BYTES, mtr); |
993 | 424 | 425 | ||
994 | 426 | if (space_id != TRX_SYS_SPACE) { | ||
995 | 427 | /* That is all we need for doublewrite buffer file. */ | ||
996 | 428 | ut_a(space_id == TRX_DOUBLEWRITE_SPACE); | ||
997 | 429 | return; | ||
998 | 430 | } | ||
999 | 431 | |||
1000 | 425 | sys_header = trx_sysf_get(mtr); | 432 | sys_header = trx_sysf_get(mtr); |
1001 | 426 | 433 | ||
1002 | 427 | /* Start counting transaction ids from number 1 up */ | 434 | /* Start counting transaction ids from number 1 up */ |
1003 | @@ -445,7 +452,7 @@ | |||
1004 | 445 | 452 | ||
1005 | 446 | /* Create the first rollback segment in the SYSTEM tablespace */ | 453 | /* Create the first rollback segment in the SYSTEM tablespace */ |
1006 | 447 | slot_no = trx_sysf_rseg_find_free(mtr); | 454 | slot_no = trx_sysf_rseg_find_free(mtr); |
1008 | 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, |
1009 | 449 | mtr); | 456 | mtr); |
1010 | 450 | 457 | ||
1011 | 451 | ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID); | 458 | ut_a(slot_no == TRX_SYS_SYSTEM_RSEG_ID); |
1012 | @@ -599,7 +606,7 @@ | |||
1013 | 599 | 606 | ||
1014 | 600 | mtr_start(&mtr); | 607 | mtr_start(&mtr); |
1015 | 601 | 608 | ||
1017 | 602 | trx_sysf_create(&mtr); | 609 | trx_sysf_create(&mtr, TRX_SYS_SPACE); |
1018 | 603 | 610 | ||
1019 | 604 | mtr_commit(&mtr); | 611 | mtr_commit(&mtr); |
1020 | 605 | } | 612 | } |
1021 | @@ -863,6 +870,26 @@ | |||
1022 | 863 | /* Does nothing at the moment */ | 870 | /* Does nothing at the moment */ |
1023 | 864 | } | 871 | } |
1024 | 865 | 872 | ||
1025 | 873 | /*****************************************************************//** | ||
1026 | 874 | Creates and initializes the dummy transaction system page for tablespace. */ | ||
1027 | 875 | UNIV_INTERN | ||
1028 | 876 | void | ||
1029 | 877 | trx_sys_dummy_create( | ||
1030 | 878 | /*=================*/ | ||
1031 | 879 | ulint space) | ||
1032 | 880 | { | ||
1033 | 881 | mtr_t mtr; | ||
1034 | 882 | |||
1035 | 883 | /* This function is only for doublewrite file for now */ | ||
1036 | 884 | ut_a(space == TRX_DOUBLEWRITE_SPACE); | ||
1037 | 885 | |||
1038 | 886 | mtr_start(&mtr); | ||
1039 | 887 | |||
1040 | 888 | trx_sysf_create(&mtr, space); | ||
1041 | 889 | |||
1042 | 890 | mtr_commit(&mtr); | ||
1043 | 891 | } | ||
1044 | 892 | |||
1045 | 866 | /********************************************************************* | 893 | /********************************************************************* |
1046 | 867 | Creates the rollback segments. | 894 | Creates the rollback segments. |
1047 | 868 | @return number of rollback segments that are active. */ | 895 | @return number of rollback segments that are active. */ |
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. doublewrite_ space() should be used everywhere it create_ low header should follow InnoDB coding style. SPACE_FIRST_ ID/SRV_ EXTRA_SYS_ SPACE_FIRST_ ID in several user_tablespace _id looks like UNIV_UNLIKELY (bug 1078206). dummy_create( ) is missing comments and misformatted in doublewrite_ space.
- 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_
applies. (bug 1078191).
- buf_dblwr_get space_id arg should have comment.
- buf_dblwr_
- s/SRV_LOG_
places (bug 1078201).
- Chunk at 410--411 looks wrong: fil_is_
a correct check already.
- Bogus UNIV_LIKELY/
- trx_sys_
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_
- Style violation at line 766.
- Too long lines at 769+, 780, 822, 825+, 857, 874
- Spurious diff at lines 428, 436, 495, 507, 576.