summaryrefslogtreecommitdiff
path: root/innobase/que/que0que.c
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/que/que0que.c')
-rw-r--r--innobase/que/que0que.c109
1 files changed, 22 insertions, 87 deletions
diff --git a/innobase/que/que0que.c b/innobase/que/que0que.c
index b2608b6d175..08bf7ce3e59 100644
--- a/innobase/que/que0que.c
+++ b/innobase/que/que0que.c
@@ -12,7 +12,6 @@ Created 5/27/1996 Heikki Tuuri
#include "que0que.ic"
#endif
-#include "srv0que.h"
#include "usr0sess.h"
#include "trx0trx.h"
#include "trx0roll.h"
@@ -175,19 +174,15 @@ a single worker thread to execute it. This function should be used to end
the wait state of a query thread waiting for a lock or a stored procedure
completion. */
-void
+que_thr_t*
que_thr_end_wait(
/*=============*/
- que_thr_t* thr, /* in: query thread in the
+ /* out: next query thread to run;
+ NULL if none */
+ que_thr_t* thr) /* in: query thread in the
QUE_THR_LOCK_WAIT,
or QUE_THR_PROCEDURE_WAIT, or
QUE_THR_SIG_REPLY_WAIT state */
- que_thr_t** next_thr) /* in/out: next query thread to run;
- if the value which is passed in is
- a pointer to a NULL pointer, then the
- calling function can start running
- a new query thread; if NULL is passed
- as the parameter, it is ignored */
{
ibool was_active;
@@ -195,6 +190,8 @@ que_thr_end_wait(
ut_ad(mutex_own(&kernel_mutex));
#endif /* UNIV_SYNC_DEBUG */
ut_ad(thr);
+ ut_ad(next_thr);
+ ut_ad(*next_thr == NULL);
ut_ad((thr->state == QUE_THR_LOCK_WAIT)
|| (thr->state == QUE_THR_PROCEDURE_WAIT)
|| (thr->state == QUE_THR_SIG_REPLY_WAIT));
@@ -206,17 +203,8 @@ que_thr_end_wait(
que_thr_move_to_run_state(thr);
- if (was_active) {
-
- return;
- }
-
- if (next_thr && *next_thr == NULL) {
- *next_thr = thr;
- } else {
- srv_que_task_enqueue_low(thr);
- }
-}
+ return(was_active ? NULL : thr);
+}
/**************************************************************************
Same as que_thr_end_wait, but no parameter next_thr available. */
@@ -253,8 +241,6 @@ que_thr_end_wait_no_next_thr(
for the lock to be released: */
srv_release_mysql_thread_if_suspended(thr);
-
- /* srv_que_task_enqueue_low(thr); */
}
/**************************************************************************
@@ -355,48 +341,6 @@ que_fork_start_command(
return(NULL);
}
-/**************************************************************************
-After signal handling is finished, returns control to a query graph error
-handling routine. (Currently, just returns the control to the root of the
-graph so that the graph can communicate an error message to the client.) */
-
-void
-que_fork_error_handle(
-/*==================*/
- trx_t* trx __attribute__((unused)), /* in: trx */
- que_t* fork) /* in: query graph which was run before signal
- handling started, NULL not allowed */
-{
- que_thr_t* thr;
-
-#ifdef UNIV_SYNC_DEBUG
- ut_ad(mutex_own(&kernel_mutex));
-#endif /* UNIV_SYNC_DEBUG */
- ut_ad(trx->sess->state == SESS_ERROR);
- ut_ad(UT_LIST_GET_LEN(trx->reply_signals) == 0);
- ut_ad(UT_LIST_GET_LEN(trx->wait_thrs) == 0);
-
- thr = UT_LIST_GET_FIRST(fork->thrs);
-
- while (thr != NULL) {
- ut_ad(!thr->is_active);
- ut_ad(thr->state != QUE_THR_SIG_REPLY_WAIT);
- ut_ad(thr->state != QUE_THR_LOCK_WAIT);
-
- thr->run_node = thr;
- thr->prev_node = thr->child;
- thr->state = QUE_THR_COMPLETED;
-
- thr = UT_LIST_GET_NEXT(thrs, thr);
- }
-
- thr = UT_LIST_GET_FIRST(fork->thrs);
-
- que_thr_move_to_run_state(thr);
-
- srv_que_task_enqueue_low(thr);
-}
-
/********************************************************************
Tests if all the query threads in the same fork have a given state. */
UNIV_INLINE
@@ -765,22 +709,18 @@ this function may only be called from inside que_run_threads or
que_thr_check_if_switch! These restrictions exist to make the rollback code
easier to maintain. */
static
-void
+que_thr_t*
que_thr_dec_refer_count(
/*====================*/
- que_thr_t* thr, /* in: query thread */
- que_thr_t** next_thr) /* in/out: next query thread to run;
- if the value which is passed in is
- a pointer to a NULL pointer, then the
- calling function can start running
- a new query thread */
+ /* out: next query thread to run */
+ que_thr_t* thr) /* in: query thread */
{
que_fork_t* fork;
trx_t* trx;
sess_t* sess;
ulint fork_type;
- ibool stopped;
-
+ que_thr_t* next_thr = NULL;
+
fork = thr->common.parent;
trx = thr->graph->trx;
sess = trx->sess;
@@ -791,9 +731,7 @@ que_thr_dec_refer_count(
if (thr->state == QUE_THR_RUNNING) {
- stopped = que_thr_stop(thr);
-
- if (!stopped) {
+ if (!que_thr_stop(thr)) {
/* The reason for the thr suspension or wait was
already canceled before we came here: continue
running the thread */
@@ -801,15 +739,9 @@ que_thr_dec_refer_count(
/* fputs("!!!!!!!! Wait already ended: continue thr\n",
stderr); */
- if (next_thr && *next_thr == NULL) {
- *next_thr = thr;
- } else {
- srv_que_task_enqueue_low(thr);
- }
-
mutex_exit(&kernel_mutex);
- return;
+ return(thr);
}
}
@@ -825,7 +757,7 @@ que_thr_dec_refer_count(
mutex_exit(&kernel_mutex);
- return;
+ return(next_thr);
}
fork_type = fork->fork_type;
@@ -841,7 +773,7 @@ que_thr_dec_refer_count(
ut_ad(UT_LIST_GET_LEN(trx->signals) > 0);
ut_ad(trx->handling_signals == TRUE);
- trx_finish_rollback_off_kernel(fork, trx, next_thr);
+ next_thr = trx_finish_rollback_off_kernel(fork, trx);
} else if (fork_type == QUE_FORK_PURGE) {
@@ -863,7 +795,7 @@ que_thr_dec_refer_count(
zero, then we start processing a signal; from it we may get
a new query thread to run */
- trx_sig_start_handle(trx, next_thr);
+ next_thr = trx_sig_start_handle(trx);
}
if (trx->handling_signals && UT_LIST_GET_LEN(trx->signals) == 0) {
@@ -872,6 +804,8 @@ que_thr_dec_refer_count(
}
mutex_exit(&kernel_mutex);
+
+ return(next_thr);
}
/**************************************************************************
@@ -1245,6 +1179,7 @@ loop:
/*-------------------------*/
next_thr = que_thr_step(thr);
/*-------------------------*/
+ ut_a(next_thr == thr || next_thr == NULL);
/* Test the effect on performance of adding extra mutex
reservations */
@@ -1257,7 +1192,7 @@ loop:
loop_count++;
if (next_thr != thr) {
- que_thr_dec_refer_count(thr, &next_thr);
+ next_thr = que_thr_dec_refer_count(thr);
if (next_thr == NULL) {