160
165
/**********************************************************************
166
Attempts to drop page hash index on a batch of pages belonging to a
167
particular space id. */
170
buf_LRU_drop_page_hash_batch(
171
/*=========================*/
172
ulint space_id, /* in: space id */
173
ulint zip_size, /* in: compressed page size in bytes
174
or 0 for uncompressed pages */
175
const ulint* arr, /* in: array of page_no */
176
ulint count) /* in: number of entries in array */
181
ut_ad(count <= BUF_LRU_DROP_SEARCH_HASH_SIZE);
183
for (i = 0; i < count; ++i) {
184
btr_search_drop_page_hash_when_freed(space_id, zip_size,
189
/**********************************************************************
190
When doing a DROP TABLE/DISCARD TABLESPACE we have to drop all page
191
hash index entries belonging to that table. This function tries to
192
do that in batch. Note that this is a 'best effort' attempt and does
193
not guarantee that ALL hash entries will be removed. */
196
buf_LRU_drop_page_hash_for_tablespace(
197
/*==================================*/
198
ulint id) /* in: space id */
205
zip_size = fil_space_get_zip_size(id);
207
if (UNIV_UNLIKELY(zip_size == ULINT_UNDEFINED)) {
208
/* Somehow, the tablespace does not exist. Nothing to drop. */
213
page_arr = ut_malloc(sizeof(ulint)
214
* BUF_LRU_DROP_SEARCH_HASH_SIZE);
215
buf_pool_mutex_enter();
219
bpage = UT_LIST_GET_LAST(buf_pool->LRU);
221
while (bpage != NULL) {
222
mutex_t* block_mutex = buf_page_get_mutex(bpage);
223
buf_page_t* prev_bpage;
225
mutex_enter(block_mutex);
226
prev_bpage = UT_LIST_GET_PREV(LRU, bpage);
228
ut_a(buf_page_in_file(bpage));
230
if (buf_page_get_state(bpage) != BUF_BLOCK_FILE_PAGE
231
|| bpage->space != id
232
|| bpage->buf_fix_count > 0
233
|| bpage->io_fix != BUF_IO_NONE) {
234
/* We leave the fixed pages as is in this scan.
235
To be dealt with later in the final scan. */
236
mutex_exit(block_mutex);
240
if (((buf_block_t*) bpage)->is_hashed) {
242
/* Store the offset(i.e.: page_no) in the array
243
so that we can drop hash index in a batch
245
page_arr[num_entries] = bpage->offset;
246
mutex_exit(block_mutex);
247
ut_a(num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE);
250
if (num_entries < BUF_LRU_DROP_SEARCH_HASH_SIZE) {
253
/* Array full. We release the buf_pool->mutex to
254
obey the latching order. */
255
buf_pool_mutex_exit();
257
buf_LRU_drop_page_hash_batch(id, zip_size, page_arr,
260
buf_pool_mutex_enter();
262
mutex_exit(block_mutex);
266
/* Note that we may have released the buf_pool mutex
267
above after reading the prev_bpage during processing
268
of a page_hash_batch (i.e.: when the array was full).
269
This means that prev_bpage can change in LRU list.
270
This is OK because this function is a 'best effort'
271
to drop as many search hash entries as possible and
272
it does not guarantee that ALL such entries will be
276
/* If, however, bpage has been removed from LRU list
277
to the free list then we should restart the scan.
278
bpage->state is protected by buf_pool mutex. */
279
if (bpage && !buf_page_in_file(bpage)) {
280
ut_a(num_entries == 0);
285
buf_pool_mutex_exit();
287
/* Drop any remaining batch of search hashed pages. */
288
buf_LRU_drop_page_hash_batch(id, zip_size, page_arr, num_entries);
292
/**********************************************************************
161
293
Invalidates all pages belonging to a given tablespace when we are deleting
162
294
the data file(s) of that tablespace. */
790
930
#if 3 * (BUF_LRU_OLD_MIN_LEN / 8) <= BUF_LRU_OLD_TOLERANCE + 5
791
931
# error "3 * (BUF_LRU_OLD_MIN_LEN / 8) <= BUF_LRU_OLD_TOLERANCE + 5"
933
#ifdef UNIV_LRU_DEBUG
934
/* buf_pool->LRU_old must be the first item in the LRU list
935
whose "old" flag is set. */
936
ut_a(buf_pool->LRU_old->old);
937
ut_a(!UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)
938
|| !UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)->old);
939
ut_a(!UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)
940
|| UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)->old);
941
#endif /* UNIV_LRU_DEBUG */
795
944
old_len = buf_pool->LRU_old_len;
796
945
new_len = 3 * (UT_LIST_GET_LEN(buf_pool->LRU) / 8);
798
947
ut_ad(buf_pool->LRU_old->in_LRU_list);
948
ut_a(buf_pool->LRU_old);
949
#ifdef UNIV_LRU_DEBUG
950
ut_a(buf_pool->LRU_old->old);
951
#endif /* UNIV_LRU_DEBUG */
800
953
/* Update the LRU_old pointer if necessary */
1044
1199
bpage->LRU_position = buf_pool_clock_tic();
1045
1200
bpage->freed_page_clock = buf_pool->freed_page_clock;
1202
#ifdef UNIV_LRU_DEBUG
1203
/* buf_pool->LRU_old must be the first item in the LRU list
1204
whose "old" flag is set. */
1205
ut_a(buf_pool->LRU_old->old);
1206
ut_a(!UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)
1207
|| !UT_LIST_GET_PREV(LRU, buf_pool->LRU_old)->old);
1208
ut_a(!UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)
1209
|| UT_LIST_GET_NEXT(LRU, buf_pool->LRU_old)->old);
1210
#endif /* UNIV_LRU_DEBUG */
1047
1211
UT_LIST_INSERT_AFTER(LRU, buf_pool->LRU, buf_pool->LRU_old,
1049
1213
buf_pool->LRU_old_len++;
1484
1667
#endif /* UNIV_ZIP_DEBUG */
1670
ut_print_timestamp(stderr);
1671
fputs(" InnoDB: ERROR: The compressed page"
1672
" to be evicted seems corrupt:", stderr);
1673
ut_print_buf(stderr, page, zip_size);
1674
fputs("\nInnoDB: Possibly older version"
1675
" of the page:", stderr);
1676
ut_print_buf(stderr, bpage->zip.data,