Commit bbb68f4c authored by unknown's avatar unknown

Added correct reaction on find operation status during writing the page. (BUG#40308)

storage/maria/ma_pagecache.c:
  Added correct reaction on find operation status during writing the page.
parent 9fb89454
...@@ -97,8 +97,9 @@ ...@@ -97,8 +97,9 @@
#define PCBLOCK_INFO(B) \ #define PCBLOCK_INFO(B) \
DBUG_PRINT("info", \ DBUG_PRINT("info", \
("block: 0x%lx fd: %lu page: %lu s: %0x hshL: 0x%lx req: %u/%u " \ ("block: 0x%lx fd: %lu page: %lu s: %0x hshL: " \
"wrlocks: %u rdlocks %u rdlocks_q: %u pins: %u", \ " 0x%lx req: %u/%u wrlocks: %u rdlocks %u " \
"rdlocks_q: %u pins: %u status: %u", \
(ulong)(B), \ (ulong)(B), \
(ulong)((B)->hash_link ? \ (ulong)((B)->hash_link ? \
(B)->hash_link->file.file : \ (B)->hash_link->file.file : \
...@@ -113,7 +114,7 @@ ...@@ -113,7 +114,7 @@
(B)->hash_link->requests : \ (B)->hash_link->requests : \
0), \ 0), \
block->wlocks, block->rlocks, block->rlocks_queue, \ block->wlocks, block->rlocks, block->rlocks_queue, \
(uint)(B)->pins)) (uint)(B)->pins, (uint)(B)->status))
/* TODO: put it to my_static.c */ /* TODO: put it to my_static.c */
my_bool my_disable_flush_pagecache_blocks= 0; my_bool my_disable_flush_pagecache_blocks= 0;
...@@ -2598,6 +2599,8 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2598,6 +2599,8 @@ static void read_block(PAGECACHE *pagecache,
{ {
DBUG_ENTER("read_block"); DBUG_ENTER("read_block");
DBUG_PRINT("enter", ("read block: 0x%lx primary: %d",
(ulong)block, primary));
if (primary) if (primary)
{ {
size_t error; size_t error;
...@@ -2606,9 +2609,6 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2606,9 +2609,6 @@ static void read_block(PAGECACHE *pagecache,
that submitted primary requests that submitted primary requests
*/ */
DBUG_PRINT("read_block",
("page to be read by primary request"));
pagecache->global_cache_read++; pagecache->global_cache_read++;
/* Page is not in buffer yet, is to be read from disk */ /* Page is not in buffer yet, is to be read from disk */
pagecache_pthread_mutex_unlock(&pagecache->cache_lock); pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
...@@ -2655,9 +2655,7 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2655,9 +2655,7 @@ static void read_block(PAGECACHE *pagecache,
This code is executed only by threads This code is executed only by threads
that submitted secondary requests that submitted secondary requests
*/ */
DBUG_PRINT("read_block",
("secondary request waiting for new page to be read"));
{
#ifdef THREAD #ifdef THREAD
struct st_my_thread_var *thread= my_thread_var; struct st_my_thread_var *thread= my_thread_var;
/* Put the request into a queue and wait until it can be processed */ /* Put the request into a queue and wait until it can be processed */
...@@ -2674,7 +2672,6 @@ static void read_block(PAGECACHE *pagecache, ...@@ -2674,7 +2672,6 @@ static void read_block(PAGECACHE *pagecache,
KEYCACHE_DBUG_ASSERT(0); KEYCACHE_DBUG_ASSERT(0);
/* No parallel requests in single-threaded case */ /* No parallel requests in single-threaded case */
#endif #endif
}
DBUG_PRINT("read_block", DBUG_PRINT("read_block",
("secondary request: new page in cache")); ("secondary request: new page in cache"));
} }
...@@ -3310,7 +3307,6 @@ uchar *pagecache_read(PAGECACHE *pagecache, ...@@ -3310,7 +3307,6 @@ uchar *pagecache_read(PAGECACHE *pagecache,
page_cache_page_type_str[type])); page_cache_page_type_str[type]));
if (((block->status & PCBLOCK_ERROR) == 0) && (page_st != PAGE_READ)) if (((block->status & PCBLOCK_ERROR) == 0) && (page_st != PAGE_READ))
{ {
DBUG_PRINT("info", ("read block 0x%lx", (ulong)block));
/* The requested page is to be read into the block buffer */ /* The requested page is to be read into the block buffer */
read_block(pagecache, block, read_block(pagecache, block,
(my_bool)(page_st == PAGE_TO_BE_READ)); (my_bool)(page_st == PAGE_TO_BE_READ));
...@@ -3845,6 +3841,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3845,6 +3841,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
{ {
/* Key cache is used */ /* Key cache is used */
int page_st; int page_st;
my_bool need_page_ready_signal= FALSE;
pagecache_pthread_mutex_lock(&pagecache->cache_lock); pagecache_pthread_mutex_lock(&pagecache->cache_lock);
if (!pagecache->can_be_used) if (!pagecache->can_be_used)
...@@ -3859,10 +3856,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3859,10 +3856,7 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
reg_request= ((pin == PAGECACHE_PIN_LEFT_UNPINNED) || reg_request= ((pin == PAGECACHE_PIN_LEFT_UNPINNED) ||
(pin == PAGECACHE_PIN)); (pin == PAGECACHE_PIN));
block= find_block(pagecache, file, pageno, level, block= find_block(pagecache, file, pageno, level,
(write_mode != PAGECACHE_WRITE_DONE && TRUE,
lock != PAGECACHE_LOCK_LEFT_WRITELOCKED &&
lock != PAGECACHE_LOCK_WRITE_UNLOCK &&
lock != PAGECACHE_LOCK_WRITE_TO_READ),
reg_request, &page_st); reg_request, &page_st);
if (!block) if (!block)
{ {
...@@ -3873,6 +3867,21 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3873,6 +3867,21 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
/* Write to the disk key cache is in resize at the moment*/ /* Write to the disk key cache is in resize at the moment*/
goto no_key_cache; goto no_key_cache;
} }
DBUG_PRINT("info", ("page status: %d", page_st));
if (!(block->status & PCBLOCK_ERROR) &&
((page_st == PAGE_TO_BE_READ &&
(offset || size < pagecache->block_size)) ||
(page_st == PAGE_WAIT_TO_BE_READ)))
{
/* The requested page is to be read into the block buffer */
read_block(pagecache, block,
(my_bool)(page_st == PAGE_TO_BE_READ));
DBUG_PRINT("info", ("read is done"));
}
else if (page_st == PAGE_TO_BE_READ)
{
need_page_ready_signal= TRUE;
}
DBUG_ASSERT(block->type == PAGECACHE_EMPTY_PAGE || DBUG_ASSERT(block->type == PAGECACHE_EMPTY_PAGE ||
block->type == PAGECACHE_READ_UNKNOWN_PAGE || block->type == PAGECACHE_READ_UNKNOWN_PAGE ||
...@@ -3959,6 +3968,12 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, ...@@ -3959,6 +3968,12 @@ my_bool pagecache_write_part(PAGECACHE *pagecache,
block->status&= ~PCBLOCK_ERROR; block->status&= ~PCBLOCK_ERROR;
} }
#ifdef THREAD
if (need_page_ready_signal &&
block->wqueue[COND_FOR_REQUESTED].last_thread)
wqueue_release_queue(&block->wqueue[COND_FOR_REQUESTED]);
#endif
if (first_REDO_LSN_for_page) if (first_REDO_LSN_for_page)
{ {
/* single write action of the last write action */ /* single write action of the last write action */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment