]>
Commit | Line | Data |
---|---|---|
8c0fcd57 ER |
1 | # name : innodb_expand_undo_slots.patch |
2 | # introduced : 11 or before | |
3 | # maintainer : Yasufumi | |
4 | # | |
5 | #!!! notice !!! | |
6 | # Any small change to this file in the main branch | |
7 | # should be done or reviewed by the maintainer! | |
4eec3829 AM |
8 | --- a/storage/innodb_plugin/handler/ha_innodb.cc |
9 | +++ b/storage/innodb_plugin/handler/ha_innodb.cc | |
8c0fcd57 ER |
10 | @@ -165,6 +165,7 @@ |
11 | #endif /* UNIV_LOG_ARCHIVE */ | |
12 | static my_bool innobase_use_doublewrite = TRUE; | |
13 | static my_bool innobase_use_checksums = TRUE; | |
14 | +static my_bool innobase_extra_undoslots = FALSE; | |
15 | static my_bool innobase_locks_unsafe_for_binlog = FALSE; | |
16 | static my_bool innobase_rollback_on_timeout = FALSE; | |
17 | static my_bool innobase_create_status_file = FALSE; | |
3700c2a6 | 18 | @@ -2124,6 +2125,8 @@ |
8c0fcd57 ER |
19 | goto error; |
20 | } | |
21 | ||
22 | + srv_extra_undoslots = (ibool) innobase_extra_undoslots; | |
23 | + | |
24 | /* -------------- Log files ---------------------------*/ | |
25 | ||
26 | /* The default dir for log files is the datadir of MySQL */ | |
3700c2a6 | 27 | @@ -10771,6 +10774,13 @@ |
8c0fcd57 ER |
28 | "The common part for InnoDB table spaces.", |
29 | NULL, NULL, NULL); | |
30 | ||
31 | +static MYSQL_SYSVAR_BOOL(extra_undoslots, innobase_extra_undoslots, | |
32 | + PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, | |
33 | + "Enable to use about 4000 undo slots instead of default 1024. " | |
34 | + "#### Attention: Once you enable this parameter, " | |
35 | + "don't use the datafile for normal mysqld or ibbackup! ####", | |
36 | + NULL, NULL, FALSE); | |
37 | + | |
38 | static MYSQL_SYSVAR_BOOL(doublewrite, innobase_use_doublewrite, | |
39 | PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY, | |
40 | "Enable InnoDB doublewrite buffer (enabled by default). " | |
3700c2a6 | 41 | @@ -11168,6 +11178,7 @@ |
8c0fcd57 ER |
42 | MYSQL_SYSVAR(data_file_path), |
43 | MYSQL_SYSVAR(data_home_dir), | |
44 | MYSQL_SYSVAR(doublewrite), | |
45 | + MYSQL_SYSVAR(extra_undoslots), | |
46 | MYSQL_SYSVAR(fast_shutdown), | |
47 | MYSQL_SYSVAR(file_io_threads), | |
48 | MYSQL_SYSVAR(read_io_threads), | |
4eec3829 AM |
49 | --- a/storage/innodb_plugin/handler/innodb_patch_info.h |
50 | +++ b/storage/innodb_plugin/handler/innodb_patch_info.h | |
8c0fcd57 ER |
51 | @@ -28,5 +28,6 @@ |
52 | {"innodb_io","Improvements to InnoDB IO","","http://www.percona.com/docs/wiki/percona-xtradb"}, | |
53 | {"innodb_opt_lru_count","Fix of buffer_pool mutex","Decreases contention on buffer_pool mutex on LRU operations","http://www.percona.com/docs/wiki/percona-xtradb"}, | |
54 | {"innodb_buffer_pool_pages","Information of buffer pool content","","http://www.percona.com/docs/wiki/percona-xtradb"}, | |
55 | +{"innodb_expand_undo_slots","expandable maximum number of undo slots","from 1024 (default) to about 4000","http://www.percona.com/docs/wiki/percona-xtradb"}, | |
56 | {NULL, NULL, NULL, NULL} | |
57 | }; | |
4eec3829 AM |
58 | --- a/storage/innodb_plugin/include/srv0srv.h |
59 | +++ b/storage/innodb_plugin/include/srv0srv.h | |
8c0fcd57 ER |
60 | @@ -112,6 +112,8 @@ |
61 | extern ulint* srv_data_file_sizes; | |
62 | extern ulint* srv_data_file_is_raw_partition; | |
63 | ||
64 | +extern ibool srv_extra_undoslots; | |
65 | + | |
66 | extern ibool srv_auto_extend_last_data_file; | |
67 | extern ulint srv_last_file_size_max; | |
68 | extern char** srv_log_group_home_dirs; | |
4eec3829 AM |
69 | --- a/storage/innodb_plugin/include/trx0rseg.h |
70 | +++ b/storage/innodb_plugin/include/trx0rseg.h | |
8c0fcd57 ER |
71 | @@ -123,8 +123,11 @@ |
72 | trx_rseg_t* rseg); /* in, own: instance to free */ | |
73 | ||
74 | ||
75 | +/* Real max value may be 4076 in usual. But reserve 4 slot for safety or etc... */ | |
76 | +#define TRX_RSEG_N_EXTRA_SLOTS (((UNIV_PAGE_SIZE - (FIL_PAGE_DATA + FIL_PAGE_DATA_END + TRX_RSEG_UNDO_SLOTS)) / TRX_RSEG_SLOT_SIZE) - 4) | |
77 | + | |
78 | /* Number of undo log slots in a rollback segment file copy */ | |
79 | -#define TRX_RSEG_N_SLOTS (UNIV_PAGE_SIZE / 16) | |
80 | +#define TRX_RSEG_N_SLOTS (srv_extra_undoslots ? TRX_RSEG_N_EXTRA_SLOTS : (UNIV_PAGE_SIZE / 16)) | |
81 | ||
82 | /* Maximum number of transactions supported by a single rollback segment */ | |
83 | #define TRX_RSEG_MAX_N_TRXS (TRX_RSEG_N_SLOTS / 2) | |
4eec3829 AM |
84 | --- a/storage/innodb_plugin/srv/srv0srv.c |
85 | +++ b/storage/innodb_plugin/srv/srv0srv.c | |
8c0fcd57 ER |
86 | @@ -142,6 +142,8 @@ |
87 | /* size in database pages */ | |
88 | UNIV_INTERN ulint* srv_data_file_sizes = NULL; | |
89 | ||
90 | +UNIV_INTERN ibool srv_extra_undoslots = FALSE; | |
91 | + | |
92 | /* if TRUE, then we auto-extend the last data file */ | |
93 | UNIV_INTERN ibool srv_auto_extend_last_data_file = FALSE; | |
94 | /* if != 0, this tells the max size auto-extending may increase the | |
4eec3829 AM |
95 | --- a/storage/innodb_plugin/trx/trx0undo.c |
96 | +++ b/storage/innodb_plugin/trx/trx0undo.c | |
97 | @@ -1396,9 +1396,47 @@ | |
8c0fcd57 ER |
98 | rseg_header = trx_rsegf_get_new(rseg->space, rseg->zip_size, |
99 | rseg->page_no, &mtr); | |
100 | ||
101 | + if (!srv_extra_undoslots) { | |
102 | + /* uses direct call for avoid "Assertion failure" */ | |
103 | + //page_no = trx_rsegf_get_nth_undo(rseg_header, TRX_RSEG_N_EXTRA_SLOTS - 1, &mtr); | |
104 | + page_no = mtr_read_ulint(rseg_header + TRX_RSEG_UNDO_SLOTS | |
105 | + + (TRX_RSEG_N_EXTRA_SLOTS - 1) * TRX_RSEG_SLOT_SIZE, | |
106 | + MLOG_4BYTES, &mtr); | |
107 | + if (page_no != 0) { | |
108 | + /* check extended slots are not used */ | |
109 | + for (i = TRX_RSEG_N_SLOTS; i < TRX_RSEG_N_EXTRA_SLOTS; i++) { | |
110 | + /* uses direct call for avoid "Assertion failure" */ | |
111 | + page_no = mtr_read_ulint(rseg_header + TRX_RSEG_UNDO_SLOTS | |
112 | + + i * TRX_RSEG_SLOT_SIZE, | |
113 | + MLOG_4BYTES, &mtr); | |
114 | + if (page_no != 0 && page_no != FIL_NULL) { | |
115 | + srv_extra_undoslots = TRUE; | |
116 | + fprintf(stderr, | |
117 | +"InnoDB: Error: innodb_extra_undoslots option is disabled, but it was enabled before.\n" | |
118 | +"InnoDB: The datafile is not normal for mysqld and disabled innodb_extra_undoslots.\n" | |
119 | +"InnoDB: Enable innodb_extra_undoslots if it was enabled before, and\n" | |
120 | +"InnoDB: ### don't use this datafile with other mysqld or ibbackup! ###\n" | |
121 | +"InnoDB: Cannot continue operation for the safety. Calling exit(1).\n"); | |
122 | + exit(1); | |
123 | + } | |
124 | + } | |
125 | + fprintf(stderr, | |
126 | +"InnoDB: Warning: innodb_extra_undoslots option is disabled, but it was enabled before.\n" | |
127 | +"InnoDB: But extended undo slots seem not used, so continue operation.\n"); | |
128 | + } | |
129 | + } | |
130 | + | |
131 | for (i = 0; i < TRX_RSEG_N_SLOTS; i++) { | |
132 | page_no = trx_rsegf_get_nth_undo(rseg_header, i, &mtr); | |
133 | ||
134 | + /* If it was not initialized when the datafile created, | |
135 | + page_no will be 0 for the extended slots after that */ | |
136 | + | |
137 | + if (page_no == 0) { | |
138 | + page_no = FIL_NULL; | |
139 | + trx_rsegf_set_nth_undo(rseg_header, i, page_no, &mtr); | |
140 | + } | |
141 | + | |
142 | /* In forced recovery: try to avoid operations which look | |
143 | at database pages; undo logs are rapidly changing data, and | |
144 | the probability that they are in an inconsistent state is |