From b55ad78aa4f8964ea3eabb673f415c0a729f3954 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 22 Aug 2022 18:36:30 +0530 Subject: MDEV-29319 Assertion failure size_in_header >= space.free_limit in fsp_get_available_space_in_free_extents() - Race condition between fsp_get_available_space_in_free_extents() and fsp_try_extend_data_file() while accessing space.free_limit. In fsp_get_available_space_in_free_extents(), take shared lock on space->latch before accessing space.free_limit and space.size_in_header --- storage/innobase/handler/ha_innodb.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index e1b645c1cc3..f749afa2627 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -14202,10 +14202,12 @@ been acquired by the caller who holds it for the calculation, @param[in] space tablespace object from fil_space_acquire() @return available space in KiB */ static uintmax_t -fsp_get_available_space_in_free_extents(const fil_space_t& space) +fsp_get_available_space_in_free_extents(fil_space_t& space) { + ut_d(rw_lock_s_lock(&space.latch)); ulint size_in_header = space.size_in_header; if (size_in_header < FSP_EXTENT_SIZE) { + ut_d(rw_lock_s_unlock(&space.latch)); return 0; /* TODO: count free frag pages and return a value based on that */ } @@ -14214,6 +14216,7 @@ fsp_get_available_space_in_free_extents(const fil_space_t& space) some of them will contain extent descriptor pages, and therefore will not be free extents */ ut_ad(size_in_header >= space.free_limit); + ut_d(rw_lock_s_unlock(&space.latch)); ulint n_free_up = (size_in_header - space.free_limit) / FSP_EXTENT_SIZE; -- cgit v1.2.1