Skip to content

Commit 81511b4

Browse files
committed
Fixed shutdown crash in Aria that affects debug binaries
MDEV-18286 Assertion `pagecache->cnt_for_resize_op == 0' failed in check_pagecache_is_cleaned_up on server shutdown The reason for the crash is that the counter-of-pinned-pages in the Aria pagecache goes wrong. This only affects debug builds, as in these we do an assert on shutdown if the counter-of-pinned-pages is not 0 (some page was left pinned). The bug was that in 2 places in the page cache, when not succeeding to pin a page and a retry was made, the counter-of-pinned-pages counter was not properly adjusted. In the given test case, BLOCK_COMMIT flushed all Aria files. If a block was flushed at the same time the insert tried to access it, the insert would retry to get the block and that would cause the counter to go wrong.
1 parent a197825 commit 81511b4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

storage/maria/ma_pagecache.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ struct st_pagecache_hash_link
152152

153153
/* simple states of a block */
154154
#define PCBLOCK_ERROR 1 /* an error occurred when performing disk i/o */
155-
#define PCBLOCK_READ 2 /* the is page in the block buffer */
155+
#define PCBLOCK_READ 2 /* there is an active page in the block buffer */
156156

157157
/*
158158
A tread is reading the data to the page.
@@ -3431,6 +3431,7 @@ uchar *pagecache_read(PAGECACHE *pagecache,
34313431
*/
34323432
if (reg_request)
34333433
unreg_request(pagecache, block, 1);
3434+
dec_counter_for_resize_op(pagecache);
34343435
pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
34353436
DBUG_PRINT("info", ("restarting..."));
34363437
goto restart;
@@ -3707,6 +3708,7 @@ my_bool pagecache_delete_by_link(PAGECACHE *pagecache,
37073708
DBUG_ASSERT((block->status &
37083709
(PCBLOCK_IN_SWITCH | PCBLOCK_REASSIGNED)) == 0);
37093710

3711+
/* This lock is deleted in pagecache_delete_internal() called below */
37103712
inc_counter_for_resize_op(pagecache);
37113713
/*
37123714
make_lock_and_pin() can't fail here, because we are keeping pin on the
@@ -3851,6 +3853,7 @@ my_bool pagecache_delete(PAGECACHE *pagecache,
38513853
*/
38523854
if (pin == PAGECACHE_PIN)
38533855
unreg_request(pagecache, block, 1);
3856+
dec_counter_for_resize_op(pagecache);
38543857
pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
38553858
DBUG_PRINT("info", ("restarting..."));
38563859
goto restart;

0 commit comments

Comments
 (0)