Commit 7270e8a3 authored by Inaam Rana's avatar Inaam Rana

Bug#16622478 INNODB'S THREAD CONCURRENCY TICKETS MIGHT BE RELEASED

AFTER A ROW IS READ


Approved by: Sunny Bains rb://2425

Don't release concurrency tickets when asked to release
btr_search_latch. This is a 5.5 only bug. It is already
fixed in 5.6 upwards.
parent 8a8a8405
......@@ -759,22 +759,18 @@ innodb_srv_conc_exit_innodb(
}
/******************************************************************//**
Releases possible search latch and InnoDB thread FIFO ticket. These should
be released at each SQL statement end, and also when mysqld passes the
control to the client. It does no harm to release these also in the middle
of an SQL statement. */
Force a thread to leave InnoDB even if it has spare tickets. */
static inline
void
innobase_release_stat_resources(
/*============================*/
trx_t* trx) /*!< in: transaction object */
innodb_srv_conc_force_exit_innodb(
/*==============================*/
trx_t* trx) /*!< in: transaction handle */
{
if (trx->has_search_latch) {
trx_search_latch_release_if_reserved(trx);
}
#ifdef UNIV_SYNC_DEBUG
ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
#endif /* UNIV_SYNC_DEBUG */
if (trx->declared_to_be_inside_innodb) {
/* Release our possible ticket in the FIFO */
srv_conc_force_exit_innodb(trx);
}
......@@ -885,9 +881,10 @@ innobase_release_temporary_latches(
trx = thd_to_trx(thd);
if (trx) {
innobase_release_stat_resources(trx);
if (trx != NULL) {
trx_search_latch_release_if_reserved(trx);
}
return(0);
}
......@@ -1853,7 +1850,8 @@ innobase_query_caching_of_table_permitted(
mutex_exit(&kernel_mutex);
}
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
......@@ -2166,7 +2164,8 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/* Initialize the prebuilt struct much like it would be inited in
external_lock */
innobase_release_stat_resources(prebuilt->trx);
trx_search_latch_release_if_reserved(prebuilt->trx);
innodb_srv_conc_force_exit_innodb(prebuilt->trx);
/* If the transaction is not started yet, start it */
......@@ -2705,7 +2704,8 @@ innobase_start_trx_and_assign_read_view(
search latch. Since we will reserve the kernel mutex, we have to
release the search system latch first to obey the latching order. */
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
/* If the transaction is not started yet, start it */
......@@ -2884,7 +2884,8 @@ innobase_rollback(
reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
trx->n_autoinc_rows = 0; /* Reset the number AUTO-INC rows required */
......@@ -2927,7 +2928,8 @@ innobase_rollback_trx(
reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
/* If we had reserved the auto-inc lock for some table (if
we come here to roll back the latest SQL statement) we
......@@ -2967,7 +2969,8 @@ innobase_rollback_to_savepoint(
reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
/* TODO: use provided savepoint data area to store savepoint data */
......@@ -3042,7 +3045,8 @@ innobase_savepoint(
reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
/* Cannot happen outside of transaction */
DBUG_ASSERT(trx_is_registered_for_2pc(trx));
......@@ -9140,7 +9144,8 @@ ha_innobase::start_stmt(
that may not be the case. We MUST release the search latch before an
INSERT, for example. */
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
/* Reset the AUTOINC statement level counter for multi-row INSERTs. */
trx->n_autoinc_rows = 0;
......@@ -9335,7 +9340,8 @@ ha_innobase::external_lock(
may reserve the kernel mutex, we have to release the search
system latch first to obey the latching order. */
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
/* If the MySQL lock count drops to zero we know that the current SQL
statement has ended */
......@@ -9488,7 +9494,8 @@ innodb_show_status(
trx = check_trx_exists(thd);
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
/* We let the InnoDB Monitor to output at most MAX_STATUS_SIZE
bytes of text. */
......@@ -10484,7 +10491,8 @@ innobase_xa_prepare(
reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */
innobase_release_stat_resources(trx);
trx_search_latch_release_if_reserved(trx);
innodb_srv_conc_force_exit_innodb(trx);
if (!trx_is_registered_for_2pc(trx) && trx_is_started(trx)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment