Commit f4894346 authored by Monty's avatar Monty

MDEV-19575 Fixed assert in ma_pagecache

There was a bug in the page cache that didn't take into account that
another thread could be waiting for a page to be read by read_big_block().
Fixed by releasing all waiters in read_big_block()
parent f44c6878
#
# MDEV-19575 Assertion `page_st == 1' failed upon SELECT from S3
# table which is being converted into Aria
#
CREATE TABLE t1 (f INT);
insert into t1 values (1),(2);
ALTER TABLE t1 ENGINE=S3;
select * from t1;
f
1
2
connect con1,localhost,root,,$database;
ALTER TABLE t1 ENGINE=Aria;
connection default;
SELECT * FROM t1;
f
1
2
connection con1;
disconnect con1;
connection default;
DROP TABLE t1;
--source include/have_s3.inc
--source create_database.inc
--echo #
--echo # MDEV-19575 Assertion `page_st == 1' failed upon SELECT from S3
--echo # table which is being converted into Aria
--echo #
CREATE TABLE t1 (f INT);
insert into t1 values (1),(2);
ALTER TABLE t1 ENGINE=S3;
select * from t1;
--connect (con1,localhost,root,,$database)
--send
ALTER TABLE t1 ENGINE=Aria;
--connection default
SELECT * FROM t1;
# Cleanup
--connection con1
--reap
--disconnect con1
--connection default
DROP TABLE t1;
#
# clean up
#
--source drop_database.inc
...@@ -2867,6 +2867,9 @@ static my_bool read_big_block(PAGECACHE *pagecache, ...@@ -2867,6 +2867,9 @@ static my_bool read_big_block(PAGECACHE *pagecache,
remove_reader(block_to_read); remove_reader(block_to_read);
unreg_request(pagecache, block_to_read, 1); unreg_request(pagecache, block_to_read, 1);
} }
/* Signal that all pending requests for this page now can be processed */
if (block->wqueue[COND_FOR_REQUESTED].last_thread)
wqueue_release_queue(&block->wqueue[COND_FOR_REQUESTED]);
DBUG_RETURN(FALSE); // no retry DBUG_RETURN(FALSE); // no retry
} }
...@@ -2940,6 +2943,8 @@ static my_bool read_big_block(PAGECACHE *pagecache, ...@@ -2940,6 +2943,8 @@ static my_bool read_big_block(PAGECACHE *pagecache,
} }
if (block->wqueue[COND_FOR_BIG_BLOCK].last_thread) if (block->wqueue[COND_FOR_BIG_BLOCK].last_thread)
wqueue_release_queue(&block->wqueue[COND_FOR_BIG_BLOCK]); wqueue_release_queue(&block->wqueue[COND_FOR_BIG_BLOCK]);
if (block->wqueue[COND_FOR_REQUESTED].last_thread)
wqueue_release_queue(&block->wqueue[COND_FOR_REQUESTED]);
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
...@@ -3684,7 +3689,7 @@ uchar *pagecache_read(PAGECACHE *pagecache, ...@@ -3684,7 +3689,7 @@ uchar *pagecache_read(PAGECACHE *pagecache,
if (((block->status & PCBLOCK_ERROR) == 0) && (page_st != PAGE_READ)) if (((block->status & PCBLOCK_ERROR) == 0) && (page_st != PAGE_READ))
{ {
#ifdef WITH_S3_STORAGE_ENGINE #ifdef WITH_S3_STORAGE_ENGINE
if (!pagecache->big_block_read) if (!pagecache->big_block_read || page_st == PAGE_WAIT_TO_BE_READ)
#endif /* WITH_S3_STORAGE_ENGINE */ #endif /* WITH_S3_STORAGE_ENGINE */
{ {
/* The requested page is to be read into the block buffer */ /* The requested page is to be read into the block buffer */
......
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