diff options
author | Annamalai Gurusami <annamalai.gurusami@oracle.com> | 2013-01-10 10:28:04 +0530 |
---|---|---|
committer | Annamalai Gurusami <annamalai.gurusami@oracle.com> | 2013-01-10 10:28:04 +0530 |
commit | a69f4a05737ec779dee9ffc73f3088ea8f504bc9 (patch) | |
tree | bdfa80f63f38d94119a566f414ae9a292abe6df2 /sql/opt_range.cc | |
parent | b36651dd2756a9c2956075caacc8c9592a22bdd6 (diff) | |
download | mariadb-git-a69f4a05737ec779dee9ffc73f3088ea8f504bc9.tar.gz |
Bug #16004999 ASSERT STATE == TRX_STATE_NOT_STARTED, UNLOCK_ROW()
Problem:
During the index intersect access method, the SQL layer will access one row,
that satisfies a set of conditions, using an index i1. And then it will try to
access the same row, with other set of conditions using the next index i2. If
the fetch from i2 fails (we are talking about an error situation here and not
simply an unmatched row situation), then it will unlock the row accessed via
i1. This will work in all situations except deadlock error.
When a deadlock happens, InnoDB will rollback the transaction. InnoDB intimates
the SQL layer about this through the THD::transaction_rollback_request member.
But this is not currently used by the SQL layer.
Solution:
When an error happens, the SQL layer must check the
THD::transaction_rollback_request member, before calling handler::unlock_row().
We have also added a debug assert in ha_innobase::unlock_row() checking that
it must be called only when the transaction is in active state.
rb#1773 approved by Marko and Sunny.
Diffstat (limited to 'sql/opt_range.cc')
-rw-r--r-- | sql/opt_range.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 96a27899db0..39f684e1928 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -8469,9 +8469,13 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() do { + DBUG_EXECUTE_IF("innodb_quick_report_deadlock", + DBUG_SET("+d,innodb_report_deadlock");); if ((error= quick->get_next())) { - quick_with_last_rowid->file->unlock_row(); + /* On certain errors like deadlock, trx might be rolled back.*/ + if (!current_thd->transaction_rollback_request) + quick_with_last_rowid->file->unlock_row(); DBUG_RETURN(error); } quick->file->position(quick->record); @@ -8494,7 +8498,9 @@ int QUICK_ROR_INTERSECT_SELECT::get_next() quick->file->unlock_row(); /* row not in range; unlock */ if ((error= quick->get_next())) { - quick_with_last_rowid->file->unlock_row(); + /* On certain errors like deadlock, trx might be rolled back.*/ + if (!current_thd->transaction_rollback_request) + quick_with_last_rowid->file->unlock_row(); DBUG_RETURN(error); } } |