Skip to content

Commit b4c9cd2

Browse files
committed
Merge 10.5 into 10.6
2 parents 101da87 + 60ed479 commit b4c9cd2

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

storage/innobase/buf/buf0buf.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,7 @@ bool buf_pool_t::create()
12271227
pthread_cond_init(&done_flush_LRU, nullptr);
12281228
pthread_cond_init(&done_flush_list, nullptr);
12291229
pthread_cond_init(&do_flush_list, nullptr);
1230+
pthread_cond_init(&done_free, nullptr);
12301231

12311232
try_LRU_scan= true;
12321233

@@ -1292,6 +1293,7 @@ void buf_pool_t::close()
12921293
pthread_cond_destroy(&done_flush_LRU);
12931294
pthread_cond_destroy(&done_flush_list);
12941295
pthread_cond_destroy(&do_flush_list);
1296+
pthread_cond_destroy(&done_free);
12951297

12961298
ut_free(chunks);
12971299
chunks= nullptr;

storage/innobase/buf/buf0flu.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,18 +392,19 @@ void buf_page_write_complete(const IORequest &request)
392392
reinterpret_cast<buf_block_t*>(bpage)->lock.u_unlock(true);
393393

394394
if (request.is_LRU())
395+
{
395396
buf_LRU_free_page(bpage, true);
396-
else
397-
ut_ad(!temp);
398397

399-
if (request.is_LRU())
400-
{
401398
ut_ad(buf_pool.n_flush_LRU_);
402399
if (!--buf_pool.n_flush_LRU_)
400+
{
403401
pthread_cond_broadcast(&buf_pool.done_flush_LRU);
402+
pthread_cond_signal(&buf_pool.done_free);
403+
}
404404
}
405405
else
406406
{
407+
ut_ad(!temp);
407408
ut_ad(buf_pool.n_flush_list_);
408409
if (!--buf_pool.n_flush_list_)
409410
pthread_cond_broadcast(&buf_pool.done_flush_list);
@@ -1676,7 +1677,10 @@ ulint buf_flush_LRU(ulint max_n)
16761677
mysql_mutex_unlock(&buf_pool.mutex);
16771678

16781679
if (!n_flushing)
1680+
{
16791681
pthread_cond_broadcast(&buf_pool.done_flush_LRU);
1682+
pthread_cond_signal(&buf_pool.done_free);
1683+
}
16801684

16811685
buf_dblwr.flush_buffered_writes();
16821686

storage/innobase/buf/buf0lru.cc

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ we put it to free list to be used.
401401
402402
@param have_mutex whether buf_pool.mutex is already being held
403403
@return the free control block, in state BUF_BLOCK_MEMORY */
404-
buf_block_t* buf_LRU_get_free_block(bool have_mutex)
404+
buf_block_t *buf_LRU_get_free_block(bool have_mutex)
405405
{
406406
ulint n_iterations = 0;
407407
ulint flush_failures = 0;
@@ -413,6 +413,7 @@ buf_block_t* buf_LRU_get_free_block(bool have_mutex)
413413
mysql_mutex_lock(&buf_pool.mutex);
414414
got_mutex:
415415
buf_LRU_check_size_of_non_data_objects();
416+
buf_block_t* block;
416417

417418
DBUG_EXECUTE_IF("ib_lru_force_no_free_page",
418419
if (!buf_lru_free_blocks_error_printed) {
@@ -421,7 +422,8 @@ buf_block_t* buf_LRU_get_free_block(bool have_mutex)
421422

422423
retry:
423424
/* If there is a block in the free list, take it */
424-
if (buf_block_t* block = buf_LRU_get_free_only()) {
425+
if ((block = buf_LRU_get_free_only()) != nullptr) {
426+
got_block:
425427
if (!have_mutex) {
426428
mysql_mutex_unlock(&buf_pool.mutex);
427429
}
@@ -446,10 +448,19 @@ buf_block_t* buf_LRU_get_free_block(bool have_mutex)
446448
buf_pool.try_LRU_scan = false;
447449
}
448450

451+
for (;;) {
452+
if ((block = buf_LRU_get_free_only()) != nullptr) {
453+
goto got_block;
454+
}
455+
if (!buf_pool.n_flush_LRU_) {
456+
break;
457+
}
458+
my_cond_wait(&buf_pool.done_free, &buf_pool.mutex.m_mutex);
459+
}
460+
449461
#ifndef DBUG_OFF
450462
not_found:
451463
#endif
452-
buf_flush_wait_batch_end(true);
453464
mysql_mutex_unlock(&buf_pool.mutex);
454465

455466
if (n_iterations > 20 && !buf_lru_free_blocks_error_printed
@@ -477,13 +488,11 @@ buf_block_t* buf_LRU_get_free_block(bool have_mutex)
477488
}
478489

479490
/* No free block was found: try to flush the LRU list.
480-
This call will flush one page from the LRU and put it on the
481-
free list. That means that the free block is up for grabs for
482-
all user threads.
491+
The freed blocks will be up for grabs for all threads.
483492
484-
TODO: A more elegant way would have been to return the freed
493+
TODO: A more elegant way would have been to return one freed
485494
up block to the caller here but the code that deals with
486-
removing the block from page_hash and LRU_list is fairly
495+
removing the block from buf_pool.page_hash and buf_pool.LRU is fairly
487496
involved (particularly in case of ROW_FORMAT=COMPRESSED pages). We
488497
can do that in a separate patch sometime in future. */
489498

@@ -1027,6 +1036,7 @@ buf_LRU_block_free_non_file_page(
10271036
} else {
10281037
UT_LIST_ADD_FIRST(buf_pool.free, &block->page);
10291038
ut_d(block->page.in_free_list = true);
1039+
pthread_cond_signal(&buf_pool.done_free);
10301040
}
10311041

10321042
MEM_NOACCESS(block->frame, srv_page_size);

storage/innobase/include/buf0buf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,8 @@ class buf_pool_t
19201920
UT_LIST_BASE_NODE_T(buf_page_t) free;
19211921
/*!< base node of the free
19221922
block list */
1923+
/** signaled each time when the free list grows; protected by mutex */
1924+
pthread_cond_t done_free;
19231925

19241926
UT_LIST_BASE_NODE_T(buf_page_t) withdraw;
19251927
/*!< base node of the withdraw

0 commit comments

Comments
 (0)