Commit 81511b47 authored by Monty's avatar Monty

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.
parent a1978252
......@@ -152,7 +152,7 @@ struct st_pagecache_hash_link
/* simple states of a block */
#define PCBLOCK_ERROR 1 /* an error occurred when performing disk i/o */
#define PCBLOCK_READ 2 /* the is page in the block buffer */
#define PCBLOCK_READ 2 /* there is an active page in the block buffer */
/*
A tread is reading the data to the page.
......@@ -3431,6 +3431,7 @@ uchar *pagecache_read(PAGECACHE *pagecache,
*/
if (reg_request)
unreg_request(pagecache, block, 1);
dec_counter_for_resize_op(pagecache);
pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
DBUG_PRINT("info", ("restarting..."));
goto restart;
......@@ -3707,6 +3708,7 @@ my_bool pagecache_delete_by_link(PAGECACHE *pagecache,
DBUG_ASSERT((block->status &
(PCBLOCK_IN_SWITCH | PCBLOCK_REASSIGNED)) == 0);
/* This lock is deleted in pagecache_delete_internal() called below */
inc_counter_for_resize_op(pagecache);
/*
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,
*/
if (pin == PAGECACHE_PIN)
unreg_request(pagecache, block, 1);
dec_counter_for_resize_op(pagecache);
pagecache_pthread_mutex_unlock(&pagecache->cache_lock);
DBUG_PRINT("info", ("restarting..."));
goto restart;
......
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