Commit 289db1b2 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 5a32bb0a
...@@ -759,22 +759,18 @@ innodb_srv_conc_exit_innodb( ...@@ -759,22 +759,18 @@ innodb_srv_conc_exit_innodb(
} }
/******************************************************************//** /******************************************************************//**
Releases possible search latch and InnoDB thread FIFO ticket. These should Force a thread to leave InnoDB even if it has spare tickets. */
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. */
static inline static inline
void void
innobase_release_stat_resources( innodb_srv_conc_force_exit_innodb(
/*============================*/ /*==============================*/
trx_t* trx) /*!< in: transaction object */ trx_t* trx) /*!< in: transaction handle */
{ {
if (trx->has_search_latch) { #ifdef UNIV_SYNC_DEBUG
trx_search_latch_release_if_reserved(trx); ut_ad(!sync_thread_levels_nonempty_trx(trx->has_search_latch));
} #endif /* UNIV_SYNC_DEBUG */
if (trx->declared_to_be_inside_innodb) { if (trx->declared_to_be_inside_innodb) {
/* Release our possible ticket in the FIFO */
srv_conc_force_exit_innodb(trx); srv_conc_force_exit_innodb(trx);
} }
...@@ -885,9 +881,10 @@ innobase_release_temporary_latches( ...@@ -885,9 +881,10 @@ innobase_release_temporary_latches(
trx = thd_to_trx(thd); trx = thd_to_trx(thd);
if (trx) { if (trx != NULL) {
innobase_release_stat_resources(trx); trx_search_latch_release_if_reserved(trx);
} }
return(0); return(0);
} }
...@@ -1853,7 +1850,8 @@ innobase_query_caching_of_table_permitted( ...@@ -1853,7 +1850,8 @@ innobase_query_caching_of_table_permitted(
mutex_exit(&kernel_mutex); 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)) { if (!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
...@@ -2166,7 +2164,8 @@ ha_innobase::init_table_handle_for_HANDLER(void) ...@@ -2166,7 +2164,8 @@ ha_innobase::init_table_handle_for_HANDLER(void)
/* Initialize the prebuilt struct much like it would be inited in /* Initialize the prebuilt struct much like it would be inited in
external_lock */ 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 */ /* If the transaction is not started yet, start it */
...@@ -2705,7 +2704,8 @@ innobase_start_trx_and_assign_read_view( ...@@ -2705,7 +2704,8 @@ innobase_start_trx_and_assign_read_view(
search latch. Since we will reserve the kernel mutex, we have to search latch. Since we will reserve the kernel mutex, we have to
release the search system latch first to obey the latching order. */ 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 */ /* If the transaction is not started yet, start it */
...@@ -2884,7 +2884,8 @@ innobase_rollback( ...@@ -2884,7 +2884,8 @@ innobase_rollback(
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */ 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 */ trx->n_autoinc_rows = 0; /* Reset the number AUTO-INC rows required */
...@@ -2927,7 +2928,8 @@ innobase_rollback_trx( ...@@ -2927,7 +2928,8 @@ innobase_rollback_trx(
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */ 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 /* If we had reserved the auto-inc lock for some table (if
we come here to roll back the latest SQL statement) we we come here to roll back the latest SQL statement) we
...@@ -2967,7 +2969,8 @@ innobase_rollback_to_savepoint( ...@@ -2967,7 +2969,8 @@ innobase_rollback_to_savepoint(
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */ 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 */ /* TODO: use provided savepoint data area to store savepoint data */
...@@ -3042,7 +3045,8 @@ innobase_savepoint( ...@@ -3042,7 +3045,8 @@ innobase_savepoint(
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */ 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 */ /* Cannot happen outside of transaction */
DBUG_ASSERT(trx_is_registered_for_2pc(trx)); DBUG_ASSERT(trx_is_registered_for_2pc(trx));
...@@ -9140,7 +9144,8 @@ ha_innobase::start_stmt( ...@@ -9140,7 +9144,8 @@ ha_innobase::start_stmt(
that may not be the case. We MUST release the search latch before an that may not be the case. We MUST release the search latch before an
INSERT, for example. */ 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. */ /* Reset the AUTOINC statement level counter for multi-row INSERTs. */
trx->n_autoinc_rows = 0; trx->n_autoinc_rows = 0;
...@@ -9335,7 +9340,8 @@ ha_innobase::external_lock( ...@@ -9335,7 +9340,8 @@ ha_innobase::external_lock(
may reserve the kernel mutex, we have to release the search may reserve the kernel mutex, we have to release the search
system latch first to obey the latching order. */ 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 /* If the MySQL lock count drops to zero we know that the current SQL
statement has ended */ statement has ended */
...@@ -9488,7 +9494,8 @@ innodb_show_status( ...@@ -9488,7 +9494,8 @@ innodb_show_status(
trx = check_trx_exists(thd); 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 /* We let the InnoDB Monitor to output at most MAX_STATUS_SIZE
bytes of text. */ bytes of text. */
...@@ -10484,7 +10491,8 @@ innobase_xa_prepare( ...@@ -10484,7 +10491,8 @@ innobase_xa_prepare(
reserve the kernel mutex, we have to release the search system latch reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */ 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)) { 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