Commit fe29dcf9 authored by sunny's avatar sunny

Modify que_fork_start_command() to do only one pass over the thread list

instead of three.
parent a40a569c
...@@ -335,6 +335,8 @@ que_fork_start_command( ...@@ -335,6 +335,8 @@ que_fork_start_command(
que_fork_t* fork) /* in: a query fork */ que_fork_t* fork) /* in: a query fork */
{ {
que_thr_t* thr; que_thr_t* thr;
que_thr_t* suspended_thr = NULL;
que_thr_t* completed_thr = NULL;
fork->state = QUE_FORK_ACTIVE; fork->state = QUE_FORK_ACTIVE;
...@@ -344,14 +346,18 @@ que_fork_start_command( ...@@ -344,14 +346,18 @@ que_fork_start_command(
but in a parallelized select, which necessarily is non-scrollable, but in a parallelized select, which necessarily is non-scrollable,
there may be several to choose from */ there may be several to choose from */
/*--------------------------------------------------------------- /* First we try to find a query thread in the QUE_THR_COMMAND_WAIT
First we try to find a query thread in the QUE_THR_COMMAND_WAIT state state. Then we try to find a query thread in the QUE_THR_SUSPENDED
*/ state, finally we try to find a query thread in the QUE_THR_COMPLETED
state */
thr = UT_LIST_GET_FIRST(fork->thrs); thr = UT_LIST_GET_FIRST(fork->thrs);
while (thr != NULL) { /* We make a single pass over the thr list within which we note which
if (thr->state == QUE_THR_COMMAND_WAIT) { threads are ready to run. */
while (thr) {
switch (thr->state) {
case QUE_THR_COMMAND_WAIT:
/* We have to send the initial message to query thread /* We have to send the initial message to query thread
to start it */ to start it */
...@@ -359,49 +365,44 @@ que_fork_start_command( ...@@ -359,49 +365,44 @@ que_fork_start_command(
que_thr_init_command(thr); que_thr_init_command(thr);
return(thr); return(thr);
}
ut_ad(thr->state != QUE_THR_LOCK_WAIT);
thr = UT_LIST_GET_NEXT(thrs, thr); case QUE_THR_SUSPENDED:
/* In this case the execution of the thread was
suspended: no initial message is needed because
execution can continue from where it was left */
if (!suspended_thr) {
suspended_thr = thr;
} }
/*---------------------------------------------------------------- break;
Then we try to find a query thread in the QUE_THR_SUSPENDED state */
thr = UT_LIST_GET_FIRST(fork->thrs); case QUE_THR_COMPLETED:
if (!completed_thr) {
completed_thr = thr;
}
while (thr != NULL) { break;
if (thr->state == QUE_THR_SUSPENDED) {
/* In this case the execution of the thread was
suspended: no initial message is needed because
execution can continue from where it was left */
que_thr_move_to_run_state(thr); case QUE_THR_LOCK_WAIT:
ut_error;
return(thr);
} }
thr = UT_LIST_GET_NEXT(thrs, thr); thr = UT_LIST_GET_NEXT(thrs, thr);
} }
/*----------------------------------------------------------------- if (suspended_thr) {
Then we try to find a query thread in the QUE_THR_COMPLETED state */
thr = UT_LIST_GET_FIRST(fork->thrs);
while (thr != NULL) { thr = suspended_thr;
if (thr->state == QUE_THR_COMPLETED) { que_thr_move_to_run_state(thr);
que_thr_init_command(thr);
return(thr); } else if (completed_thr) {
}
thr = UT_LIST_GET_NEXT(thrs, thr); thr = completed_thr;
que_thr_init_command(thr);
} }
/* Else we return NULL */ return(thr);
return(NULL);
} }
/************************************************************************** /**************************************************************************
......
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