Merge lp:~laurynas-biveinis/percona-server/bug1279671 into lp:percona-server/5.6

Proposed by Laurynas Biveinis
Status: Merged
Approved by: Alexey Kopytov
Approved revision: 543
Merged at revision: 549
Proposed branch: lp:~laurynas-biveinis/percona-server/bug1279671
Merge into: lp:percona-server/5.6
Prerequisite: lp:~laurynas-biveinis/percona-server/merge-5.6.16
Diff against target: 308 lines (+66/-33)
12 files modified
storage/innobase/dict/dict0boot.cc (+8/-4)
storage/innobase/dict/dict0dict.cc (+3/-2)
storage/innobase/dict/dict0load.cc (+2/-1)
storage/innobase/dict/dict0mem.cc (+32/-12)
storage/innobase/fts/fts0fts.cc (+1/-1)
storage/innobase/handler/ha_innodb.cc (+3/-3)
storage/innobase/handler/handler0alter.cc (+1/-1)
storage/innobase/ibuf/ibuf0ibuf.cc (+3/-2)
storage/innobase/include/dict0mem.h (+10/-4)
storage/innobase/mtr/mtr0log.cc (+1/-1)
storage/innobase/page/page0zip.cc (+1/-1)
storage/innobase/pars/pars0pars.cc (+1/-1)
To merge this branch: bzr merge lp:~laurynas-biveinis/percona-server/bug1279671
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+206734@code.launchpad.net

Description of the change

Fix bug 1279671: upstream fix for
http://bugs.mysql.com/bug.php?id=70768 causes RW lock creations and
destructions at a high rate during ibuf merge.

The fix for upstream 70768 removed the static array of 64 shared
latches that were used for dict_table_t stat field protection and
replaced it with a new field dict_table_t::stats_latch that is
dynamically initialized in dict_mem_table_create and destroyed in
dict_mem_table_free.

This was unconditional for dummy dict_table_t objects too, that are
created by the ibuf merge, compressed page decompression, crash
recovery, and the dummy indexes for redundant and compact row record
format supremum and infimum records. Some of these might such as ibuf
merge may get created and destroyed at a high enough rate so that the
additional rwlock creation and destroy becomes a bottleneck.

Since the dummy dict_table_t objects do not participate in query
optimizer stat calculations, do not construct and destroy stats_latch
for them. At the same time, since such objects do not participate in
user transactions nor have auto increment fields, do not construct
autoinc_lock nor autoinc_mutex fields neither.

http://jenkins.percona.com/job/percona-server-5.6-param/521/

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storage/innobase/dict/dict0boot.cc'
2--- storage/innobase/dict/dict0boot.cc 2013-10-23 08:48:28 +0000
3+++ storage/innobase/dict/dict0boot.cc 2014-02-17 14:55:46 +0000
4@@ -302,7 +302,8 @@
5 /* Insert into the dictionary cache the descriptions of the basic
6 system tables */
7 /*-------------------------*/
8- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0);
9+ table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0,
10+ false);
11
12 dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
13 dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
14@@ -356,7 +357,8 @@
15 ut_a(error == DB_SUCCESS);
16
17 /*-------------------------*/
18- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0);
19+ table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0,
20+ false);
21
22 dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
23 dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
24@@ -389,7 +391,8 @@
25 ut_a(error == DB_SUCCESS);
26
27 /*-------------------------*/
28- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0);
29+ table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0,
30+ false);
31
32 dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
33 dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
34@@ -422,7 +425,8 @@
35 ut_a(error == DB_SUCCESS);
36
37 /*-------------------------*/
38- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0);
39+ table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0,
40+ false);
41
42 dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0);
43 dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
44
45=== modified file 'storage/innobase/dict/dict0dict.cc'
46--- storage/innobase/dict/dict0dict.cc 2014-02-17 14:55:28 +0000
47+++ storage/innobase/dict/dict0dict.cc 2014-02-17 14:55:46 +0000
48@@ -5718,7 +5718,8 @@
49 dict_table_t* table;
50
51 /* create dummy table and index for REDUNDANT infimum and supremum */
52- table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0);
53+ table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0,
54+ true);
55 dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
56 DATA_ENGLISH | DATA_NOT_NULL, 8);
57
58@@ -5731,7 +5732,7 @@
59 /* create dummy table and index for COMPACT infimum and supremum */
60 table = dict_mem_table_create("SYS_DUMMY2",
61 DICT_HDR_SPACE, 1,
62- DICT_TF_COMPACT, 0);
63+ DICT_TF_COMPACT, 0, true);
64 dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
65 DATA_ENGLISH | DATA_NOT_NULL, 8);
66 dict_ind_compact = dict_mem_index_create("SYS_DUMMY2", "SYS_DUMMY2",
67
68=== modified file 'storage/innobase/dict/dict0load.cc'
69--- storage/innobase/dict/dict0load.cc 2014-02-17 14:55:28 +0000
70+++ storage/innobase/dict/dict0load.cc 2014-02-17 14:55:46 +0000
71@@ -2175,7 +2175,8 @@
72
73 /* See if the tablespace is available. */
74 *table = dict_mem_table_create(
75- name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2);
76+ name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2,
77+ false);
78
79 field = rec_get_nth_field_old(rec, DICT_FLD__SYS_TABLES__ID, &len);
80 ut_ad(len == 8); /* this was checked earlier */
81
82=== modified file 'storage/innobase/dict/dict0mem.cc'
83--- storage/innobase/dict/dict0mem.cc 2014-02-17 14:55:28 +0000
84+++ storage/innobase/dict/dict0mem.cc 2014-02-17 14:55:46 +0000
85@@ -65,7 +65,10 @@
86 the table is placed */
87 ulint n_cols, /*!< in: number of columns */
88 ulint flags, /*!< in: table flags */
89- ulint flags2) /*!< in: table flags2 */
90+ ulint flags2, /*!< in: table flags2 */
91+ bool nonshared)/*!< in: whether the table object is a dummy
92+ one that does not need the initialization of
93+ locking-related fields. */
94 {
95 dict_table_t* table;
96 mem_heap_t* heap;
97@@ -95,16 +98,27 @@
98
99 ut_d(table->magic_n = DICT_TABLE_MAGIC_N);
100
101- table->stats_latch = new rw_lock_t;
102- rw_lock_create(dict_table_stats_latch_key, table->stats_latch,
103- SYNC_INDEX_TREE);
104+ if (!nonshared) {
105+ table->stats_latch = new rw_lock_t;
106+ rw_lock_create(dict_table_stats_latch_key, table->stats_latch,
107+ SYNC_INDEX_TREE);
108+ } else {
109+ table->stats_latch = NULL;
110+ }
111
112 #ifndef UNIV_HOTBACKUP
113- table->autoinc_lock = static_cast<ib_lock_t*>(
114- mem_heap_alloc(heap, lock_get_size()));
115-
116- mutex_create(autoinc_mutex_key,
117- &table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
118+
119+ if (!nonshared) {
120+
121+ table->autoinc_lock = static_cast<ib_lock_t*>(
122+ mem_heap_alloc(heap, lock_get_size()));
123+
124+ mutex_create(autoinc_mutex_key,
125+ &table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
126+ } else {
127+
128+ table->autoinc_lock = NULL;
129+ }
130
131 table->autoinc = 0;
132
133@@ -154,11 +168,17 @@
134 }
135 }
136 #ifndef UNIV_HOTBACKUP
137- mutex_free(&(table->autoinc_mutex));
138+ if (table->stats_latch) {
139+
140+ mutex_free(&(table->autoinc_mutex));
141+ }
142 #endif /* UNIV_HOTBACKUP */
143
144- rw_lock_free(table->stats_latch);
145- delete table->stats_latch;
146+ if (table->stats_latch) {
147+
148+ rw_lock_free(table->stats_latch);
149+ delete table->stats_latch;
150+ }
151
152 ut_free(table->name);
153 mem_heap_free(table->heap);
154
155=== modified file 'storage/innobase/fts/fts0fts.cc'
156--- storage/innobase/fts/fts0fts.cc 2014-02-17 14:55:28 +0000
157+++ storage/innobase/fts/fts0fts.cc 2014-02-17 14:55:46 +0000
158@@ -1950,7 +1950,7 @@
159
160 ut_ad(index->type & DICT_FTS);
161
162- new_table = dict_mem_table_create(table_name, 0, 5, 1, 0);
163+ new_table = dict_mem_table_create(table_name, 0, 5, 1, 0, false);
164
165 field = dict_index_get_nth_field(index, 0);
166 charset = innobase_get_fts_charset(
167
168=== modified file 'storage/innobase/handler/ha_innodb.cc'
169--- storage/innobase/handler/ha_innodb.cc 2014-02-17 14:55:28 +0000
170+++ storage/innobase/handler/ha_innodb.cc 2014-02-17 14:55:46 +0000
171@@ -9144,18 +9144,18 @@
172 /* Adjust for the FTS hidden field */
173 if (!has_doc_id_col) {
174 table = dict_mem_table_create(table_name, 0, n_cols + 1,
175- flags, flags2);
176+ flags, flags2, false);
177
178 /* Set the hidden doc_id column. */
179 table->fts->doc_col = n_cols;
180 } else {
181 table = dict_mem_table_create(table_name, 0, n_cols,
182- flags, flags2);
183+ flags, flags2, false);
184 table->fts->doc_col = doc_id_col;
185 }
186 } else {
187 table = dict_mem_table_create(table_name, 0, n_cols,
188- flags, flags2);
189+ flags, flags2, false);
190 }
191
192 if (flags2 & DICT_TF2_TEMPORARY) {
193
194=== modified file 'storage/innobase/handler/handler0alter.cc'
195--- storage/innobase/handler/handler0alter.cc 2014-02-17 14:55:28 +0000
196+++ storage/innobase/handler/handler0alter.cc 2014-02-17 14:55:46 +0000
197@@ -2732,7 +2732,7 @@
198
199 /* The initial space id 0 may be overridden later. */
200 ctx->new_table = dict_mem_table_create(
201- new_table_name, 0, n_cols, flags, flags2);
202+ new_table_name, 0, n_cols, flags, flags2, false);
203 /* The rebuilt indexed_table will use the renamed
204 column names. */
205 ctx->col_names = NULL;
206
207=== modified file 'storage/innobase/ibuf/ibuf0ibuf.cc'
208--- storage/innobase/ibuf/ibuf0ibuf.cc 2013-12-16 08:45:31 +0000
209+++ storage/innobase/ibuf/ibuf0ibuf.cc 2014-02-17 14:55:46 +0000
210@@ -611,7 +611,8 @@
211 heap = mem_heap_create(450);
212
213 /* Use old-style record format for the insert buffer. */
214- table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0, 0);
215+ table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0, 0,
216+ false);
217
218 dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0);
219
220@@ -1572,7 +1573,7 @@
221
222 table = dict_mem_table_create("IBUF_DUMMY",
223 DICT_HDR_SPACE, n,
224- comp ? DICT_TF_COMPACT : 0, 0);
225+ comp ? DICT_TF_COMPACT : 0, 0, true);
226
227 index = dict_mem_index_create("IBUF_DUMMY", "IBUF_DUMMY",
228 DICT_HDR_SPACE, 0, n);
229
230=== modified file 'storage/innobase/include/dict0mem.h'
231--- storage/innobase/include/dict0mem.h 2014-02-17 14:55:28 +0000
232+++ storage/innobase/include/dict0mem.h 2014-02-17 14:55:46 +0000
233@@ -259,7 +259,10 @@
234 of the table is placed */
235 ulint n_cols, /*!< in: number of columns */
236 ulint flags, /*!< in: table flags */
237- ulint flags2); /*!< in: table flags2 */
238+ ulint flags2, /*!< in: table flags2 */
239+ bool nonshared);/*!< in: whether the table object is a dummy
240+ one that does not need the initialization of
241+ locking-related fields. */
242 /****************************************************************//**
243 Free a table memory object. */
244 UNIV_INTERN
245@@ -860,7 +863,8 @@
246 dict_table_t::indexes*::stat_index_size
247 dict_table_t::indexes*::stat_n_leaf_pages
248 (*) those are not always protected for
249- performance reasons */
250+ performance reasons. NULL for dumy table
251+ objects. */
252 unsigned stat_initialized:1; /*!< TRUE if statistics have
253 been calculated the first time
254 after database startup or table creation */
255@@ -982,10 +986,12 @@
256 and release it without a need to allocate
257 space from the lock heap of the trx:
258 otherwise the lock heap would grow rapidly
259- if we do a large insert from a select */
260+ if we do a large insert from a select. NULL
261+ for dummy table objects. */
262 ib_mutex_t autoinc_mutex;
263 /*!< mutex protecting the autoincrement
264- counter */
265+ counter. Not initialized for dummy table
266+ objects */
267 ib_uint64_t autoinc;/*!< autoinc counter value to give to the
268 next inserted row */
269 ulong n_waiting_or_granted_auto_inc_locks;
270
271=== modified file 'storage/innobase/mtr/mtr0log.cc'
272--- storage/innobase/mtr/mtr0log.cc 2013-08-06 15:16:34 +0000
273+++ storage/innobase/mtr/mtr0log.cc 2014-02-17 14:55:46 +0000
274@@ -560,7 +560,7 @@
275 n = n_uniq = 1;
276 }
277 table = dict_mem_table_create("LOG_DUMMY", DICT_HDR_SPACE, n,
278- comp ? DICT_TF_COMPACT : 0, 0);
279+ comp ? DICT_TF_COMPACT : 0, 0, true);
280 ind = dict_mem_index_create("LOG_DUMMY", "LOG_DUMMY",
281 DICT_HDR_SPACE, 0, n);
282 ind->table = table;
283
284=== modified file 'storage/innobase/page/page0zip.cc'
285--- storage/innobase/page/page0zip.cc 2014-02-17 14:55:28 +0000
286+++ storage/innobase/page/page0zip.cc 2014-02-17 14:55:46 +0000
287@@ -1623,7 +1623,7 @@
288 }
289
290 table = dict_mem_table_create("ZIP_DUMMY", DICT_HDR_SPACE, n,
291- DICT_TF_COMPACT, 0);
292+ DICT_TF_COMPACT, 0, true);
293 index = dict_mem_index_create("ZIP_DUMMY", "ZIP_DUMMY",
294 DICT_HDR_SPACE, 0, n);
295 index->table = table;
296
297=== modified file 'storage/innobase/pars/pars0pars.cc'
298--- storage/innobase/pars/pars0pars.cc 2014-02-17 14:55:28 +0000
299+++ storage/innobase/pars/pars0pars.cc 2014-02-17 14:55:46 +0000
300@@ -1997,7 +1997,7 @@
301 n_cols = que_node_list_get_len(column_defs);
302
303 table = dict_mem_table_create(
304- table_sym->name, 0, n_cols, flags, flags2);
305+ table_sym->name, 0, n_cols, flags, flags2, false);
306
307 #ifdef UNIV_DEBUG
308 if (not_fit_in_memory != NULL) {

Subscribers

People subscribed via source and target branches