]>
Commit | Line | Data |
---|---|---|
b4e1fa2c AM |
1 | # name : innodb_dict_size_limit.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! | |
8 | diff -ruN a/storage/innobase/btr/btr0sea.c b/storage/innobase/btr/btr0sea.c | |
9 | --- a/storage/innobase/btr/btr0sea.c 2010-11-03 07:01:13.000000000 +0900 | |
10 | +++ b/storage/innobase/btr/btr0sea.c 2010-12-03 15:45:47.503988924 +0900 | |
d8778560 | 11 | @@ -1185,6 +1185,179 @@ |
b4e1fa2c AM |
12 | mem_free(folds); |
13 | } | |
14 | ||
15 | +/************************************************************************ | |
16 | +Drops a page hash index based on index */ | |
17 | +UNIV_INTERN | |
18 | +void | |
19 | +btr_search_drop_page_hash_index_on_index( | |
20 | +/*=====================================*/ | |
21 | + dict_index_t* index) /* in: record descriptor */ | |
22 | +{ | |
d8778560 | 23 | + |
b4e1fa2c AM |
24 | + hash_table_t* table; |
25 | + buf_block_t* block; | |
26 | + ulint n_fields; | |
27 | + ulint n_bytes; | |
28 | + const page_t* page; | |
29 | + const rec_t* rec; | |
30 | + ulint fold; | |
31 | + ulint prev_fold; | |
32 | + index_id_t index_id; | |
33 | + ulint n_cached; | |
34 | + ulint n_recs; | |
35 | + ulint* folds; | |
36 | + ulint i, j; | |
37 | + mem_heap_t* heap = NULL; | |
38 | + ulint* offsets; | |
d8778560 | 39 | + ibool released_search_latch; |
b4e1fa2c | 40 | + |
d8778560 | 41 | + rw_lock_s_lock(&btr_search_latch); |
b4e1fa2c AM |
42 | + |
43 | + table = btr_search_sys->hash_index; | |
44 | + | |
45 | + for (j = 0; j < srv_buf_pool_instances; j++) { | |
46 | + buf_pool_t* buf_pool; | |
47 | + | |
48 | + buf_pool = buf_pool_from_array(j); | |
49 | + | |
d8778560 AM |
50 | + do { |
51 | + buf_chunk_t* chunks = buf_pool->chunks; | |
52 | + buf_chunk_t* chunk = chunks + buf_pool->n_chunks; | |
53 | + | |
54 | + released_search_latch = FALSE; | |
55 | + | |
56 | + while (--chunk >= chunks) { | |
57 | + block = chunk->blocks; | |
58 | + i = chunk->size; | |
59 | + | |
60 | +retry: | |
61 | + for (; i--; block++) { | |
62 | + if (buf_block_get_state(block) | |
63 | + != BUF_BLOCK_FILE_PAGE | |
64 | + || block->index != index | |
65 | + || !block->is_hashed) { | |
66 | + continue; | |
67 | + } | |
68 | + | |
69 | + page = block->frame; | |
70 | + | |
71 | + /* from btr_search_drop_page_hash_index() */ | |
72 | + n_fields = block->curr_n_fields; | |
73 | + n_bytes = block->curr_n_bytes; | |
74 | + | |
b4e1fa2c | 75 | + |
d8778560 AM |
76 | + /* keeping latch order */ |
77 | + rw_lock_s_unlock(&btr_search_latch); | |
78 | + released_search_latch = TRUE; | |
79 | + rw_lock_x_lock(&block->lock); | |
b4e1fa2c | 80 | + |
b4e1fa2c | 81 | + |
d8778560 | 82 | + ut_a(n_fields + n_bytes > 0); |
b4e1fa2c | 83 | + |
d8778560 | 84 | + n_recs = page_get_n_recs(page); |
b4e1fa2c | 85 | + |
d8778560 AM |
86 | + /* Calculate and cache fold values into an array for fast deletion |
87 | + from the hash index */ | |
b4e1fa2c | 88 | + |
d8778560 | 89 | + folds = mem_alloc(n_recs * sizeof(ulint)); |
b4e1fa2c | 90 | + |
d8778560 | 91 | + n_cached = 0; |
b4e1fa2c | 92 | + |
d8778560 AM |
93 | + rec = page_get_infimum_rec(page); |
94 | + rec = page_rec_get_next_low(rec, page_is_comp(page)); | |
b4e1fa2c | 95 | + |
d8778560 | 96 | + index_id = btr_page_get_index_id(page); |
b4e1fa2c | 97 | + |
d8778560 | 98 | + ut_a(index_id == index->id); |
b4e1fa2c | 99 | + |
d8778560 | 100 | + prev_fold = 0; |
b4e1fa2c | 101 | + |
d8778560 | 102 | + offsets = NULL; |
b4e1fa2c | 103 | + |
d8778560 AM |
104 | + while (!page_rec_is_supremum(rec)) { |
105 | + offsets = rec_get_offsets(rec, index, offsets, | |
106 | + n_fields + (n_bytes > 0), &heap); | |
107 | + ut_a(rec_offs_n_fields(offsets) == n_fields + (n_bytes > 0)); | |
108 | + fold = rec_fold(rec, offsets, n_fields, n_bytes, index_id); | |
b4e1fa2c | 109 | + |
d8778560 | 110 | + if (fold == prev_fold && prev_fold != 0) { |
b4e1fa2c | 111 | + |
d8778560 AM |
112 | + goto next_rec; |
113 | + } | |
b4e1fa2c | 114 | + |
d8778560 AM |
115 | + /* Remove all hash nodes pointing to this page from the |
116 | + hash chain */ | |
b4e1fa2c | 117 | + |
d8778560 AM |
118 | + folds[n_cached] = fold; |
119 | + n_cached++; | |
b4e1fa2c | 120 | +next_rec: |
d8778560 AM |
121 | + rec = page_rec_get_next_low(rec, page_rec_is_comp(rec)); |
122 | + prev_fold = fold; | |
123 | + } | |
b4e1fa2c | 124 | + |
d8778560 AM |
125 | + if (UNIV_LIKELY_NULL(heap)) { |
126 | + mem_heap_empty(heap); | |
127 | + } | |
b4e1fa2c | 128 | + |
d8778560 | 129 | + rw_lock_x_lock(&btr_search_latch); |
b4e1fa2c | 130 | + |
d8778560 AM |
131 | + if (UNIV_UNLIKELY(!block->is_hashed)) { |
132 | + goto cleanup; | |
133 | + } | |
b4e1fa2c | 134 | + |
d8778560 AM |
135 | + ut_a(block->index == index); |
136 | + | |
137 | + if (UNIV_UNLIKELY(block->curr_n_fields != n_fields) | |
138 | + || UNIV_UNLIKELY(block->curr_n_bytes != n_bytes)) { | |
139 | + rw_lock_x_unlock(&btr_search_latch); | |
140 | + rw_lock_x_unlock(&block->lock); | |
141 | + | |
142 | + mem_free(folds); | |
143 | + | |
144 | + rw_lock_s_lock(&btr_search_latch); | |
145 | + goto retry; | |
146 | + } | |
147 | + | |
148 | + for (i = 0; i < n_cached; i++) { | |
149 | + | |
150 | + ha_remove_all_nodes_to_page(table, folds[i], page); | |
151 | + } | |
152 | + | |
153 | + ut_a(index->search_info->ref_count > 0); | |
154 | + index->search_info->ref_count--; | |
155 | + | |
156 | + block->is_hashed = FALSE; | |
157 | + block->index = NULL; | |
158 | + | |
159 | +cleanup: | |
b4e1fa2c | 160 | +#if defined UNIV_AHI_DEBUG || defined UNIV_DEBUG |
d8778560 AM |
161 | + if (UNIV_UNLIKELY(block->n_pointers)) { |
162 | + /* Corruption */ | |
163 | + ut_print_timestamp(stderr); | |
164 | + fprintf(stderr, | |
165 | +"InnoDB: The adaptive hash index is corrupted. After dropping\n" | |
166 | +"InnoDB: the hash index to a page of %s, %lu hash nodes still remain.\n", | |
167 | + index->name, (ulong) block->n_pointers); | |
168 | + } | |
b4e1fa2c | 169 | +#endif /* UNIV_AHI_DEBUG || UNIV_DEBUG */ |
d8778560 AM |
170 | + rw_lock_x_unlock(&btr_search_latch); |
171 | + rw_lock_x_unlock(&block->lock); | |
b4e1fa2c | 172 | + |
d8778560 | 173 | + mem_free(folds); |
b4e1fa2c | 174 | + |
d8778560 AM |
175 | + rw_lock_s_lock(&btr_search_latch); |
176 | + } | |
177 | + } | |
178 | + } while (released_search_latch); | |
b4e1fa2c AM |
179 | + } |
180 | + | |
d8778560 | 181 | + rw_lock_s_unlock(&btr_search_latch); |
b4e1fa2c AM |
182 | + |
183 | + if (UNIV_LIKELY_NULL(heap)) { | |
184 | + mem_heap_free(heap); | |
185 | + } | |
186 | +} | |
187 | + | |
188 | /********************************************************************//** | |
189 | Drops a page hash index when a page is freed from a fseg to the file system. | |
190 | Drops possible hash index if the page happens to be in the buffer pool. */ | |
d8778560 AM |
191 | diff -ruN a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c |
192 | --- a/storage/innobase/buf/buf0buf.c 2011-02-01 18:00:03.000000000 +0900 | |
193 | +++ b/storage/innobase/buf/buf0buf.c 2011-02-01 18:01:59.000000000 +0900 | |
194 | @@ -294,14 +294,14 @@ | |
195 | # endif /* !PFS_SKIP_BUFFER_MUTEX_RWLOCK */ | |
196 | #endif /* UNIV_PFS_MUTEX || UNIV_PFS_RWLOCK */ | |
197 | ||
198 | -/** A chunk of buffers. The buffer pool is allocated in chunks. */ | |
199 | -struct buf_chunk_struct{ | |
200 | - ulint mem_size; /*!< allocated size of the chunk */ | |
201 | - ulint size; /*!< size of frames[] and blocks[] */ | |
202 | - void* mem; /*!< pointer to the memory area which | |
203 | - was allocated for the frames */ | |
204 | - buf_block_t* blocks; /*!< array of buffer control blocks */ | |
205 | -}; | |
206 | +/** A chunk of buffers. The buffer pool is allocated in chunks. (moved to buf0buf.h)*/ | |
207 | +//struct buf_chunk_struct{ | |
208 | +// ulint mem_size; /*!< allocated size of the chunk */ | |
209 | +// ulint size; /*!< size of frames[] and blocks[] */ | |
210 | +// void* mem; /*!< pointer to the memory area which | |
211 | +// was allocated for the frames */ | |
212 | +// buf_block_t* blocks; /*!< array of buffer control blocks */ | |
213 | +//}; | |
214 | #endif /* !UNIV_HOTBACKUP */ | |
215 | ||
216 | /********************************************************************//** | |
b4e1fa2c AM |
217 | diff -ruN a/storage/innobase/dict/dict0boot.c b/storage/innobase/dict/dict0boot.c |
218 | --- a/storage/innobase/dict/dict0boot.c 2010-11-03 07:01:13.000000000 +0900 | |
219 | +++ b/storage/innobase/dict/dict0boot.c 2010-12-03 15:45:47.503988924 +0900 | |
220 | @@ -284,6 +284,7 @@ | |
221 | system tables */ | |
222 | /*-------------------------*/ | |
223 | table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0); | |
224 | + table->n_mysql_handles_opened = 1; /* for pin */ | |
225 | ||
226 | dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0); | |
227 | dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0); | |
228 | @@ -336,6 +337,7 @@ | |
229 | ||
230 | /*-------------------------*/ | |
231 | table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0); | |
232 | + table->n_mysql_handles_opened = 1; /* for pin */ | |
233 | ||
234 | dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0); | |
235 | dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4); | |
236 | @@ -368,6 +370,7 @@ | |
237 | ||
238 | /*-------------------------*/ | |
239 | table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0); | |
240 | + table->n_mysql_handles_opened = 1; /* for pin */ | |
241 | ||
242 | dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0); | |
243 | dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0); | |
244 | @@ -413,6 +416,7 @@ | |
245 | ||
246 | /*-------------------------*/ | |
247 | table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0); | |
248 | + table->n_mysql_handles_opened = 1; /* for pin */ | |
249 | ||
250 | dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0); | |
251 | dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4); | |
252 | diff -ruN a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c | |
253 | --- a/storage/innobase/dict/dict0crea.c 2010-11-03 07:01:13.000000000 +0900 | |
254 | +++ b/storage/innobase/dict/dict0crea.c 2010-12-03 15:45:47.521955810 +0900 | |
255 | @@ -1210,6 +1210,9 @@ | |
256 | /* Foreign constraint system tables have already been | |
257 | created, and they are ok */ | |
258 | ||
259 | + table1->n_mysql_handles_opened = 1; /* for pin */ | |
260 | + table2->n_mysql_handles_opened = 1; /* for pin */ | |
261 | + | |
262 | mutex_exit(&(dict_sys->mutex)); | |
263 | ||
264 | return(DB_SUCCESS); | |
265 | @@ -1291,6 +1294,11 @@ | |
266 | ||
267 | trx_commit_for_mysql(trx); | |
268 | ||
269 | + table1 = dict_table_get_low("SYS_FOREIGN"); | |
270 | + table2 = dict_table_get_low("SYS_FOREIGN_COLS"); | |
271 | + table1->n_mysql_handles_opened = 1; /* for pin */ | |
272 | + table2->n_mysql_handles_opened = 1; /* for pin */ | |
273 | + | |
274 | row_mysql_unlock_data_dictionary(trx); | |
275 | ||
276 | trx_free_for_mysql(trx); | |
277 | diff -ruN a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c | |
278 | --- a/storage/innobase/dict/dict0dict.c 2010-11-03 07:01:13.000000000 +0900 | |
279 | +++ b/storage/innobase/dict/dict0dict.c 2010-12-03 15:45:47.525953769 +0900 | |
d8778560 | 280 | @@ -627,6 +627,8 @@ |
b4e1fa2c AM |
281 | |
282 | table = dict_table_get_on_id_low(table_id); | |
283 | ||
284 | + dict_table_LRU_trim(table); | |
285 | + | |
286 | mutex_exit(&(dict_sys->mutex)); | |
287 | ||
288 | return(table); | |
d8778560 | 289 | @@ -745,6 +747,8 @@ |
b4e1fa2c AM |
290 | table->n_mysql_handles_opened++; |
291 | } | |
292 | ||
293 | + dict_table_LRU_trim(table); | |
294 | + | |
295 | mutex_exit(&(dict_sys->mutex)); | |
296 | ||
297 | if (table != NULL) { | |
d8778560 | 298 | @@ -1260,6 +1264,64 @@ |
b4e1fa2c AM |
299 | dict_mem_table_free(table); |
300 | } | |
301 | ||
302 | +/************************************************************************** | |
303 | +Frees tables from the end of table_LRU if the dictionary cache occupies | |
304 | +too much space. */ | |
305 | +UNIV_INTERN | |
306 | +void | |
307 | +dict_table_LRU_trim( | |
308 | +/*================*/ | |
309 | + dict_table_t* self) | |
310 | +{ | |
311 | + dict_table_t* table; | |
312 | + dict_table_t* prev_table; | |
313 | + dict_foreign_t* foreign; | |
314 | + ulint n_removed; | |
315 | + ulint n_have_parent; | |
316 | + ulint cached_foreign_tables; | |
317 | + | |
318 | +#ifdef UNIV_SYNC_DEBUG | |
319 | + ut_ad(mutex_own(&(dict_sys->mutex))); | |
320 | +#endif /* UNIV_SYNC_DEBUG */ | |
321 | + | |
322 | +retry: | |
323 | + n_removed = n_have_parent = 0; | |
324 | + table = UT_LIST_GET_LAST(dict_sys->table_LRU); | |
325 | + | |
326 | + while ( srv_dict_size_limit && table | |
327 | + && ((dict_sys->table_hash->n_cells | |
328 | + + dict_sys->table_id_hash->n_cells) * sizeof(hash_cell_t) | |
329 | + + dict_sys->size) > srv_dict_size_limit ) { | |
330 | + prev_table = UT_LIST_GET_PREV(table_LRU, table); | |
331 | + | |
332 | + if (table == self || table->n_mysql_handles_opened) | |
333 | + goto next_loop; | |
334 | + | |
335 | + cached_foreign_tables = 0; | |
336 | + foreign = UT_LIST_GET_FIRST(table->foreign_list); | |
337 | + while (foreign != NULL) { | |
338 | + if (foreign->referenced_table) | |
339 | + cached_foreign_tables++; | |
340 | + foreign = UT_LIST_GET_NEXT(foreign_list, foreign); | |
341 | + } | |
342 | + | |
343 | + if (cached_foreign_tables == 0) { | |
344 | + dict_table_remove_from_cache(table); | |
345 | + n_removed++; | |
346 | + } else { | |
347 | + n_have_parent++; | |
348 | + } | |
349 | +next_loop: | |
350 | + table = prev_table; | |
351 | + } | |
352 | + | |
353 | + if ( srv_dict_size_limit && n_have_parent && n_removed | |
354 | + && ((dict_sys->table_hash->n_cells | |
355 | + + dict_sys->table_id_hash->n_cells) * sizeof(hash_cell_t) | |
356 | + + dict_sys->size) > srv_dict_size_limit ) | |
357 | + goto retry; | |
358 | +} | |
359 | + | |
360 | /****************************************************************//** | |
361 | If the given column name is reserved for InnoDB system columns, return | |
362 | TRUE. | |
d8778560 | 363 | @@ -1723,6 +1785,11 @@ |
b4e1fa2c AM |
364 | ut_ad(index->magic_n == DICT_INDEX_MAGIC_N); |
365 | ut_ad(mutex_own(&(dict_sys->mutex))); | |
366 | ||
367 | + /* remove all entry of the index from adaptive hash index, | |
368 | + because removing from adaptive hash index needs dict_index */ | |
369 | + if (btr_search_enabled && srv_dict_size_limit) | |
370 | + btr_search_drop_page_hash_index_on_index(index); | |
371 | + | |
372 | /* We always create search info whether or not adaptive | |
373 | hash index is enabled or not. */ | |
374 | info = index->search_info; | |
375 | diff -ruN a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc | |
376 | --- a/storage/innobase/handler/ha_innodb.cc 2010-12-03 15:43:57.294986852 +0900 | |
377 | +++ b/storage/innobase/handler/ha_innodb.cc 2010-12-03 15:45:47.534959966 +0900 | |
d8778560 | 378 | @@ -656,6 +656,8 @@ |
b4e1fa2c AM |
379 | (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG}, |
380 | {"dblwr_writes", | |
381 | (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG}, | |
382 | + {"dict_tables", | |
383 | + (char*) &export_vars.innodb_dict_tables, SHOW_LONG}, | |
384 | {"have_atomic_builtins", | |
385 | (char*) &export_vars.innodb_have_atomic_builtins, SHOW_BOOL}, | |
386 | {"log_waits", | |
d8778560 | 387 | @@ -11536,6 +11538,11 @@ |
b4e1fa2c AM |
388 | "Number of extra user rollback segments which are used in a round-robin fashion.", |
389 | NULL, NULL, 127, 0, 127, 0); | |
390 | ||
391 | +static MYSQL_SYSVAR_ULONG(dict_size_limit, srv_dict_size_limit, | |
392 | + PLUGIN_VAR_RQCMDARG, | |
393 | + "Limit the allocated memory for dictionary cache. (0: unlimited)", | |
394 | + NULL, NULL, 0, 0, LONG_MAX, 0); | |
395 | + | |
396 | static struct st_mysql_sys_var* innobase_system_variables[]= { | |
397 | MYSQL_SYSVAR(additional_mem_pool_size), | |
398 | MYSQL_SYSVAR(autoextend_increment), | |
d8778560 AM |
399 | @@ -11603,6 +11610,7 @@ |
400 | MYSQL_SYSVAR(read_ahead), | |
b4e1fa2c | 401 | MYSQL_SYSVAR(adaptive_flushing_method), |
b4e1fa2c AM |
402 | MYSQL_SYSVAR(extra_rsegments), |
403 | + MYSQL_SYSVAR(dict_size_limit), | |
404 | MYSQL_SYSVAR(use_sys_malloc), | |
405 | MYSQL_SYSVAR(use_native_aio), | |
406 | MYSQL_SYSVAR(change_buffering), | |
407 | diff -ruN a/storage/innobase/ibuf/ibuf0ibuf.c b/storage/innobase/ibuf/ibuf0ibuf.c | |
408 | --- a/storage/innobase/ibuf/ibuf0ibuf.c 2010-12-03 15:18:48.889024455 +0900 | |
409 | +++ b/storage/innobase/ibuf/ibuf0ibuf.c 2010-12-03 15:45:47.553025057 +0900 | |
410 | @@ -578,6 +578,7 @@ | |
411 | ||
412 | /* Use old-style record format for the insert buffer. */ | |
413 | table = dict_mem_table_create(IBUF_TABLE_NAME, IBUF_SPACE_ID, 1, 0); | |
414 | + table->n_mysql_handles_opened = 1; /* for pin */ | |
415 | ||
416 | dict_mem_table_add_col(table, heap, "DUMMY_COLUMN", DATA_BINARY, 0, 0); | |
417 | ||
418 | diff -ruN a/storage/innobase/include/btr0sea.h b/storage/innobase/include/btr0sea.h | |
419 | --- a/storage/innobase/include/btr0sea.h 2010-11-03 07:01:13.000000000 +0900 | |
420 | +++ b/storage/innobase/include/btr0sea.h 2010-12-03 15:45:47.555024229 +0900 | |
421 | @@ -140,6 +140,13 @@ | |
422 | s- or x-latched, or an index page | |
423 | for which we know that | |
424 | block->buf_fix_count == 0 */ | |
425 | +/************************************************************************ | |
426 | +Drops a page hash index based on index */ | |
427 | +UNIV_INTERN | |
428 | +void | |
429 | +btr_search_drop_page_hash_index_on_index( | |
430 | +/*=====================================*/ | |
431 | + dict_index_t* index); /* in: record descriptor */ | |
432 | /********************************************************************//** | |
433 | Drops a page hash index when a page is freed from a fseg to the file system. | |
434 | Drops possible hash index if the page happens to be in the buffer pool. */ | |
d8778560 AM |
435 | diff -ruN a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h |
436 | --- a/storage/innobase/include/buf0buf.h 2011-02-01 18:00:03.000000000 +0900 | |
437 | +++ b/storage/innobase/include/buf0buf.h 2011-02-01 18:03:29.000000000 +0900 | |
438 | @@ -1553,6 +1553,15 @@ | |
439 | #define BUF_POOL_ZIP_FOLD_BPAGE(b) BUF_POOL_ZIP_FOLD((buf_block_t*) (b)) | |
440 | /* @} */ | |
441 | ||
442 | +/** A chunk of buffers. The buffer pool is allocated in chunks. */ | |
443 | +struct buf_chunk_struct{ | |
444 | + ulint mem_size; /*!< allocated size of the chunk */ | |
445 | + ulint size; /*!< size of frames[] and blocks[] */ | |
446 | + void* mem; /*!< pointer to the memory area which | |
447 | + was allocated for the frames */ | |
448 | + buf_block_t* blocks; /*!< array of buffer control blocks */ | |
449 | +}; | |
450 | + | |
451 | /** @brief The buffer pool statistics structure. */ | |
452 | struct buf_pool_stat_struct{ | |
453 | ulint n_page_gets; /*!< number of page gets performed; | |
b4e1fa2c AM |
454 | diff -ruN a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h |
455 | --- a/storage/innobase/include/dict0dict.h 2010-11-03 07:01:13.000000000 +0900 | |
456 | +++ b/storage/innobase/include/dict0dict.h 2010-12-03 15:45:47.558024515 +0900 | |
457 | @@ -1158,6 +1158,12 @@ | |
458 | /*====================================*/ | |
459 | dict_table_t* table, /*!< in: table */ | |
460 | const char* name); /*!< in: name of the index to find */ | |
461 | + | |
462 | +UNIV_INTERN | |
463 | +void | |
464 | +dict_table_LRU_trim( | |
465 | +/*================*/ | |
466 | + dict_table_t* self); | |
467 | /* Buffers for storing detailed information about the latest foreign key | |
468 | and unique key errors */ | |
469 | extern FILE* dict_foreign_err_file; | |
470 | diff -ruN a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic | |
471 | --- a/storage/innobase/include/dict0dict.ic 2010-11-03 07:01:13.000000000 +0900 | |
472 | +++ b/storage/innobase/include/dict0dict.ic 2010-12-03 15:45:47.560024398 +0900 | |
473 | @@ -824,6 +824,13 @@ | |
474 | HASH_SEARCH(name_hash, dict_sys->table_hash, table_fold, | |
475 | dict_table_t*, table, ut_ad(table->cached), | |
476 | !strcmp(table->name, table_name)); | |
477 | + | |
478 | + /* make young in table_LRU */ | |
479 | + if (table) { | |
480 | + UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table); | |
481 | + UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table); | |
482 | + } | |
483 | + | |
484 | return(table); | |
485 | } | |
486 | ||
487 | @@ -877,6 +884,12 @@ | |
488 | table = dict_load_table_on_id(table_id); | |
489 | } | |
490 | ||
491 | + /* make young in table_LRU */ | |
492 | + if (table) { | |
493 | + UT_LIST_REMOVE(table_LRU, dict_sys->table_LRU, table); | |
494 | + UT_LIST_ADD_FIRST(table_LRU, dict_sys->table_LRU, table); | |
495 | + } | |
496 | + | |
497 | ut_ad(!table || table->cached); | |
498 | ||
499 | /* TODO: should get the type information from MySQL */ | |
500 | diff -ruN a/storage/innobase/include/srv0srv.h b/storage/innobase/include/srv0srv.h | |
501 | --- a/storage/innobase/include/srv0srv.h 2010-12-03 15:43:57.297067100 +0900 | |
502 | +++ b/storage/innobase/include/srv0srv.h 2010-12-03 15:45:47.562024404 +0900 | |
503 | @@ -228,7 +228,7 @@ | |
504 | extern ulint srv_adaptive_flushing_method; | |
505 | ||
506 | extern ulint srv_extra_rsegments; | |
507 | - | |
508 | +extern ulint srv_dict_size_limit; | |
509 | /*-------------------------------------------*/ | |
510 | ||
511 | extern ulint srv_n_rows_inserted; | |
d8778560 | 512 | @@ -708,6 +708,7 @@ |
b4e1fa2c AM |
513 | ulint innodb_data_writes; /*!< I/O write requests */ |
514 | ulint innodb_data_written; /*!< Data bytes written */ | |
515 | ulint innodb_data_reads; /*!< I/O read requests */ | |
516 | + ulint innodb_dict_tables; | |
517 | ulint innodb_buffer_pool_pages_total; /*!< Buffer pool size */ | |
518 | ulint innodb_buffer_pool_pages_data; /*!< Data pages */ | |
519 | ulint innodb_buffer_pool_pages_dirty; /*!< Dirty data pages */ | |
520 | diff -ruN a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c | |
521 | --- a/storage/innobase/srv/srv0srv.c 2010-12-03 15:43:57.301024390 +0900 | |
522 | +++ b/storage/innobase/srv/srv0srv.c 2010-12-03 15:45:47.565023830 +0900 | |
d8778560 | 523 | @@ -416,6 +416,7 @@ |
b4e1fa2c AM |
524 | UNIV_INTERN ulint srv_adaptive_flushing_method = 0; /* 0: native 1: estimate 2: keep_average */ |
525 | ||
526 | UNIV_INTERN ulint srv_extra_rsegments = 127; /* extra rseg for users */ | |
527 | +UNIV_INTERN ulint srv_dict_size_limit = 0; | |
528 | /*-------------------------------------------*/ | |
529 | UNIV_INTERN ulong srv_n_spin_wait_rounds = 30; | |
530 | UNIV_INTERN ulong srv_n_free_tickets_to_enter = 500; | |
d8778560 | 531 | @@ -2226,6 +2227,7 @@ |
b4e1fa2c AM |
532 | export_vars.innodb_data_reads = os_n_file_reads; |
533 | export_vars.innodb_data_writes = os_n_file_writes; | |
534 | export_vars.innodb_data_written = srv_data_written; | |
535 | + export_vars.innodb_dict_tables= (dict_sys ? UT_LIST_GET_LEN(dict_sys->table_LRU) : 0); | |
536 | export_vars.innodb_buffer_pool_read_requests = stat.n_page_gets; | |
537 | export_vars.innodb_buffer_pool_write_requests | |
538 | = srv_buf_pool_write_requests; |