Skip to content

Commit

Permalink
MDEV-11197: TrxInInnoDB::is_aborted(const trx_t*): Assertion `srv_rea…
Browse files Browse the repository at this point in the history
…d_only_mode || trx->in_depth > 0' failed

TrxInInnoDB should be constructed to track if a transaction is executing
inside InnoDB code i.e. it is like a gate between Server and InnoDB
::rnd_next() is called from Server and thus construct TrxInInnoDB
also there.

Applied suggested clean-up to TrxInInnoDB class functions enter()
and exit(). Note that exactly original did not work for enter().
  • Loading branch information
Jan Lindström committed May 10, 2017
1 parent 00821c3 commit f4df8c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions storage/innobase/handler/ha_innodb.cc
Expand Up @@ -10574,6 +10574,8 @@ ha_innobase::rnd_next(

DBUG_ENTER("rnd_next");

TrxInInnoDB trx_in_innodb(m_prebuilt->trx);

if (m_start_of_scan) {
error = index_first(buf);

Expand Down
17 changes: 7 additions & 10 deletions storage/innobase/include/trx0trx.h
Expand Up @@ -1508,17 +1508,15 @@ class TrxInInnoDB {
}

/* Avoid excessive mutex acquire/release */
++trx->in_depth;

/* If trx->in_depth is greater than 1 then
transaction is already in InnoDB. */
if (trx->in_depth > 1) {

if (++trx->in_depth > 1) {
/* The transaction is already inside InnoDB. */
ut_ad(trx->in_depth > 1);
return;
}

/* Only the owning thread should release the latch. */

ut_ad(trx->in_depth == 1);
trx_assert_no_search_latch(trx);

trx_mutex_enter(trx);
Expand All @@ -1545,15 +1543,14 @@ class TrxInInnoDB {

ut_ad(trx->in_depth > 0);

--trx->in_depth;

if (trx->in_depth > 0) {

if (--trx->in_depth > 0) {
ut_ad(trx->in_depth);
return;
}

/* Only the owning thread should release the latch. */

ut_ad(trx->in_depth == 0);
trx_assert_no_search_latch(trx);

trx_mutex_enter(trx);
Expand Down

0 comments on commit f4df8c0

Please sign in to comment.