Skip to content

Commit 867724f

Browse files
committed
MDEV-25125 Assertion failure in fetch_data_into_cache_low()
Before MDEV-14638, there was no race condition between the execution of fetch_data_into_cache() and transaction commit. fetch_data_into_cache(): Acquire trx_t::mutex before checking trx_t::state, to prevent a concurrent transition from TRX_STATE_COMMITTED_IN_MEMORY to TRX_STATE_NOT_STARTED in trx_commit_in_memory().
1 parent 19052b6 commit 867724f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

storage/innobase/trx/trx0i_s.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2017, 2019, MariaDB Corporation.
4+
Copyright (c) 2017, 2021, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -1262,13 +1262,16 @@ static void fetch_data_into_cache(trx_i_s_cache_t *cache)
12621262

12631263
/* Capture the state of transactions */
12641264
mutex_enter(&trx_sys.mutex);
1265-
for (const trx_t *trx= UT_LIST_GET_FIRST(trx_sys.trx_list);
1265+
for (trx_t *trx= UT_LIST_GET_FIRST(trx_sys.trx_list);
12661266
trx != NULL;
12671267
trx= UT_LIST_GET_NEXT(trx_list, trx))
12681268
{
1269-
if (trx_is_started(trx) && trx != purge_sys.query->trx)
1269+
if (trx->state != TRX_STATE_NOT_STARTED && trx != purge_sys.query->trx)
12701270
{
1271-
fetch_data_into_cache_low(cache, trx);
1271+
mutex_enter(&trx->mutex);
1272+
if (trx->state != TRX_STATE_NOT_STARTED)
1273+
fetch_data_into_cache_low(cache, trx);
1274+
mutex_exit(&trx->mutex);
12721275
if (cache->is_truncated)
12731276
break;
12741277
}

0 commit comments

Comments
 (0)