Skip to content

Commit f489434

Browse files
committed
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()
1 parent f44c687 commit f489434

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

mysql-test/suite/s3/alter2.result

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# MDEV-19575 Assertion `page_st == 1' failed upon SELECT from S3
3+
# table which is being converted into Aria
4+
#
5+
CREATE TABLE t1 (f INT);
6+
insert into t1 values (1),(2);
7+
ALTER TABLE t1 ENGINE=S3;
8+
select * from t1;
9+
f
10+
1
11+
2
12+
connect con1,localhost,root,,$database;
13+
ALTER TABLE t1 ENGINE=Aria;
14+
connection default;
15+
SELECT * FROM t1;
16+
f
17+
1
18+
2
19+
connection con1;
20+
disconnect con1;
21+
connection default;
22+
DROP TABLE t1;

mysql-test/suite/s3/alter2.test

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--source include/have_s3.inc
2+
--source create_database.inc
3+
4+
--echo #
5+
--echo # MDEV-19575 Assertion `page_st == 1' failed upon SELECT from S3
6+
--echo # table which is being converted into Aria
7+
--echo #
8+
9+
CREATE TABLE t1 (f INT);
10+
insert into t1 values (1),(2);
11+
12+
ALTER TABLE t1 ENGINE=S3;
13+
select * from t1;
14+
--connect (con1,localhost,root,,$database)
15+
--send
16+
ALTER TABLE t1 ENGINE=Aria;
17+
18+
--connection default
19+
SELECT * FROM t1;
20+
21+
# Cleanup
22+
23+
--connection con1
24+
--reap
25+
--disconnect con1
26+
--connection default
27+
DROP TABLE t1;
28+
29+
#
30+
# clean up
31+
#
32+
--source drop_database.inc

storage/maria/ma_pagecache.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2867,6 +2867,9 @@ static my_bool read_big_block(PAGECACHE *pagecache,
28672867
remove_reader(block_to_read);
28682868
unreg_request(pagecache, block_to_read, 1);
28692869
}
2870+
/* Signal that all pending requests for this page now can be processed */
2871+
if (block->wqueue[COND_FOR_REQUESTED].last_thread)
2872+
wqueue_release_queue(&block->wqueue[COND_FOR_REQUESTED]);
28702873
DBUG_RETURN(FALSE); // no retry
28712874
}
28722875

@@ -2940,6 +2943,8 @@ static my_bool read_big_block(PAGECACHE *pagecache,
29402943
}
29412944
if (block->wqueue[COND_FOR_BIG_BLOCK].last_thread)
29422945
wqueue_release_queue(&block->wqueue[COND_FOR_BIG_BLOCK]);
2946+
if (block->wqueue[COND_FOR_REQUESTED].last_thread)
2947+
wqueue_release_queue(&block->wqueue[COND_FOR_REQUESTED]);
29432948

29442949
DBUG_RETURN(FALSE);
29452950
}
@@ -3684,7 +3689,7 @@ uchar *pagecache_read(PAGECACHE *pagecache,
36843689
if (((block->status & PCBLOCK_ERROR) == 0) && (page_st != PAGE_READ))
36853690
{
36863691
#ifdef WITH_S3_STORAGE_ENGINE
3687-
if (!pagecache->big_block_read)
3692+
if (!pagecache->big_block_read || page_st == PAGE_WAIT_TO_BE_READ)
36883693
#endif /* WITH_S3_STORAGE_ENGINE */
36893694
{
36903695
/* The requested page is to be read into the block buffer */

0 commit comments

Comments
 (0)