summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-03-18 13:36:02 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-03-18 13:36:02 +0200
commit867724fd304caf714d3cd2aa825f2c8b3b724017 (patch)
tree4b3dce339158d8a7e95bc543e976893286909169
parent19052b6debc1aeb4ef6ccbc36cdc92c10cf968b6 (diff)
downloadmariadb-git-867724fd304caf714d3cd2aa825f2c8b3b724017.tar.gz
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().
-rw-r--r--storage/innobase/trx/trx0i_s.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/storage/innobase/trx/trx0i_s.cc b/storage/innobase/trx/trx0i_s.cc
index 54425ae934b..71872ce45b2 100644
--- a/storage/innobase/trx/trx0i_s.cc
+++ b/storage/innobase/trx/trx0i_s.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2015, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2019, MariaDB Corporation.
+Copyright (c) 2017, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
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)
/* Capture the state of transactions */
mutex_enter(&trx_sys.mutex);
- for (const trx_t *trx= UT_LIST_GET_FIRST(trx_sys.trx_list);
+ for (trx_t *trx= UT_LIST_GET_FIRST(trx_sys.trx_list);
trx != NULL;
trx= UT_LIST_GET_NEXT(trx_list, trx))
{
- if (trx_is_started(trx) && trx != purge_sys.query->trx)
+ if (trx->state != TRX_STATE_NOT_STARTED && trx != purge_sys.query->trx)
{
- fetch_data_into_cache_low(cache, trx);
+ mutex_enter(&trx->mutex);
+ if (trx->state != TRX_STATE_NOT_STARTED)
+ fetch_data_into_cache_low(cache, trx);
+ mutex_exit(&trx->mutex);
if (cache->is_truncated)
break;
}