46 #define QUE_PARALLELIZE_LIMIT (64 * 256 * 256 * 256)
47 #define QUE_ROUND_ROBIN_LIMIT (64 * 256 * 256 * 256)
48 #define QUE_MAX_LOOPS_WITHOUT_CHECK 16
53 UNIV_INTERN ibool que_trace_on = FALSE;
133 que_thr_move_to_run_state(
146 ut_ad(mutex_own(&kernel_mutex));
174 fork->
state = QUE_FORK_COMMAND_WAIT;
209 ut_ad(parent && heap);
216 thr->
magic_n = QUE_THR_MAGIC_N;
220 thr->
state = QUE_THR_COMMAND_WAIT;
255 ut_ad(mutex_own(&kernel_mutex));
258 || (thr->
state == QUE_THR_PROCEDURE_WAIT)
259 || (thr->
state == QUE_THR_SIG_REPLY_WAIT));
266 que_thr_move_to_run_state(thr);
273 if (next_thr && *next_thr == NULL) {
295 ut_ad(mutex_own(&kernel_mutex));
298 || (thr->
state == QUE_THR_PROCEDURE_WAIT)
299 || (thr->
state == QUE_THR_SIG_REPLY_WAIT));
303 que_thr_move_to_run_state(thr);
322 que_thr_init_command(
329 que_thr_move_to_run_state(thr);
350 fork->
state = QUE_FORK_ACTIVE;
354 suspended_thr = NULL;
355 completed_thr = NULL;
371 switch (thr->
state) {
372 case QUE_THR_COMMAND_WAIT:
377 que_thr_init_command(thr);
381 case QUE_THR_SUSPENDED:
385 if (!suspended_thr) {
391 case QUE_THR_COMPLETED:
392 if (!completed_thr) {
398 case QUE_THR_LOCK_WAIT:
409 que_thr_move_to_run_state(thr);
411 }
else if (completed_thr) {
414 que_thr_init_command(thr);
434 ut_ad(mutex_own(&kernel_mutex));
435 ut_ad(trx->sess->state == SESS_ERROR);
441 while (thr != NULL) {
448 thr->
state = QUE_THR_COMPLETED;
455 que_thr_move_to_run_state(thr);
467 que_fork_all_thrs_in_state(
476 while (thr_node != NULL) {
477 if (thr_node->
state != state) {
492 que_graph_free_stat_list(
545 if (thr->
magic_n != QUE_THR_MAGIC_N) {
547 "que_thr struct appears corrupt;"
554 thr->
magic_n = QUE_THR_MAGIC_FREED;
566 case QUE_NODE_SELECT:
573 case QUE_NODE_INSERT:
589 case QUE_NODE_UPDATE:
593 if (upd->in_mysql_interface) {
600 if (upd->cascade_heap) {
609 case QUE_NODE_CREATE_TABLE:
619 case QUE_NODE_CREATE_INDEX:
630 que_graph_free_stat_list(((
proc_node_t*)node)->stat_list);
634 que_graph_free_stat_list(((
if_node_t*)node)->stat_list);
635 que_graph_free_stat_list(((
if_node_t*)node)->else_part);
636 que_graph_free_stat_list(((
if_node_t*)node)->elsif_list);
640 que_graph_free_stat_list(((
elsif_node_t*)node)->stat_list);
644 que_graph_free_stat_list(((
while_node_t*)node)->stat_list);
648 que_graph_free_stat_list(((
for_node_t*)node)->stat_list);
652 case QUE_NODE_ASSIGNMENT:
654 case QUE_NODE_RETURN:
655 case QUE_NODE_COMMIT:
656 case QUE_NODE_ROLLBACK:
660 case QUE_NODE_ROW_PRINTF:
668 "que_node struct appears corrupt; type %lu\n",
727 mutex_enter(&kernel_mutex);
731 mutex_exit(&kernel_mutex);
738 thr->
state = QUE_THR_COMPLETED;
740 mutex_exit(&kernel_mutex);
753 que_thr_move_to_run_state(
765 (thr->
graph)->n_active_thrs++;
775 thr->
state = QUE_THR_RUNNING;
788 que_thr_dec_refer_count(
805 mutex_enter(&kernel_mutex);
809 if (thr->
state == QUE_THR_RUNNING) {
821 if (next_thr && *next_thr == NULL) {
834 mutex_exit(&kernel_mutex);
850 mutex_exit(&kernel_mutex);
859 if (que_fork_all_thrs_in_state(fork, QUE_THR_COMPLETED)) {
862 case QUE_FORK_ROLLBACK:
867 ut_ad(trx->handling_signals == TRUE);
873 case QUE_FORK_RECOVERY:
874 case QUE_FORK_MYSQL_INTERFACE:
898 mutex_exit(&kernel_mutex);
916 ut_ad(mutex_own(&kernel_mutex));
921 if (graph->
state == QUE_FORK_COMMAND_WAIT) {
922 thr->
state = QUE_THR_SUSPENDED;
924 }
else if (trx->
que_state == TRX_QUE_LOCK_WAIT) {
927 thr->
state = QUE_THR_LOCK_WAIT;
933 thr->
state = QUE_THR_COMPLETED;
936 && graph->
fork_type != QUE_FORK_ROLLBACK) {
938 thr->
state = QUE_THR_SUSPENDED;
963 mutex_enter(&kernel_mutex);
965 if (thr->
state == QUE_THR_RUNNING) {
971 thr->
state = QUE_THR_COMPLETED;
977 mutex_exit(&kernel_mutex);
988 (thr->
graph)->n_active_thrs--;
992 mutex_exit(&kernel_mutex);
1006 if (thr->
magic_n != QUE_THR_MAGIC_N) {
1008 "que_thr struct appears corrupt; magic n %lu\n",
1009 (
unsigned long) thr->
magic_n);
1025 thr->
state = QUE_THR_RUNNING;
1043 if (thr->
magic_n != QUE_THR_MAGIC_N) {
1045 "que_thr struct appears corrupt; magic n %lu\n",
1046 (
unsigned long) thr->
magic_n);
1053 thr->
state = QUE_THR_COMPLETED;
1056 (thr->
graph)->n_active_thrs--;
1084 if ((type == QUE_NODE_FOR) || (type == QUE_NODE_WHILE)) {
1105 if (type == QUE_NODE_SELECT) {
1107 }
else if (type == QUE_NODE_INSERT) {
1109 }
else if (type == QUE_NODE_UPDATE) {
1111 }
else if (type == QUE_NODE_WHILE) {
1113 }
else if (type == QUE_NODE_ASSIGNMENT) {
1115 }
else if (type == QUE_NODE_IF) {
1117 }
else if (type == QUE_NODE_FETCH) {
1119 }
else if (type == QUE_NODE_OPEN) {
1121 }
else if (type == QUE_NODE_PROC) {
1122 str =
"STORED PROCEDURE";
1123 }
else if (type == QUE_NODE_FUNC) {
1125 }
else if (type == QUE_NODE_LOCK) {
1127 }
else if (type == QUE_NODE_THR) {
1128 str =
"QUERY THREAD";
1129 }
else if (type == QUE_NODE_COMMIT) {
1131 }
else if (type == QUE_NODE_UNDO) {
1133 }
else if (type == QUE_NODE_PURGE) {
1135 }
else if (type == QUE_NODE_ROLLBACK) {
1137 }
else if (type == QUE_NODE_CREATE_TABLE) {
1138 str =
"CREATE TABLE";
1139 }
else if (type == QUE_NODE_CREATE_INDEX) {
1140 str =
"CREATE INDEX";
1141 }
else if (type == QUE_NODE_FOR) {
1143 }
else if (type == QUE_NODE_RETURN) {
1145 }
else if (type == QUE_NODE_EXIT) {
1148 str =
"UNKNOWN NODE TYPE";
1151 fprintf(stderr,
"Node type %lu: %s, address %p\n",
1152 (ulong) type, str, (
void*) node);
1184 fputs(
"To execute: ", stderr);
1188 if (type & QUE_NODE_CONTROL_STAT) {
1198 }
else if (type == QUE_NODE_IF) {
1200 }
else if (type == QUE_NODE_FOR) {
1202 }
else if (type == QUE_NODE_PROC) {
1214 }
else if (type == QUE_NODE_WHILE) {
1219 }
else if (type == QUE_NODE_ASSIGNMENT) {
1221 }
else if (type == QUE_NODE_SELECT) {
1223 }
else if (type == QUE_NODE_INSERT) {
1225 }
else if (type == QUE_NODE_UPDATE) {
1227 }
else if (type == QUE_NODE_FETCH) {
1229 }
else if (type == QUE_NODE_OPEN) {
1231 }
else if (type == QUE_NODE_FUNC) {
1234 }
else if (type == QUE_NODE_LOCK) {
1240 }
else if (type == QUE_NODE_THR) {
1241 thr = que_thr_node_step(thr);
1242 }
else if (type == QUE_NODE_COMMIT) {
1244 }
else if (type == QUE_NODE_UNDO) {
1246 }
else if (type == QUE_NODE_PURGE) {
1248 }
else if (type == QUE_NODE_RETURN) {
1250 }
else if (type == QUE_NODE_EXIT) {
1252 }
else if (type == QUE_NODE_ROLLBACK) {
1254 }
else if (type == QUE_NODE_CREATE_TABLE) {
1256 }
else if (type == QUE_NODE_CREATE_INDEX) {
1258 }
else if (type == QUE_NODE_ROW_PRINTF) {
1264 if (type == QUE_NODE_EXIT) {
1281 que_run_threads_low(
1290 ut_ad(!mutex_own(&kernel_mutex));
1292 loop_count = QUE_MAX_LOOPS_WITHOUT_CHECK;
1305 next_thr = que_thr_step(thr);
1308 ut_a(!next_thr || (
thr_get_trx(next_thr)->error_state == DB_SUCCESS));
1312 if (next_thr != thr) {
1313 ut_a(next_thr == NULL);
1317 que_thr_dec_refer_count(thr, &next_thr);
1319 if (next_thr == NULL) {
1324 loop_count = QUE_MAX_LOOPS_WITHOUT_CHECK;
1342 que_run_threads_low(thr);
1344 mutex_enter(&kernel_mutex);
1346 switch (thr->
state) {
1348 case QUE_THR_RUNNING:
1352 mutex_exit(&kernel_mutex);
1356 case QUE_THR_LOCK_WAIT:
1357 mutex_exit(&kernel_mutex);
1364 if (
thr_get_trx(thr)->error_state != DB_SUCCESS) {
1368 que_thr_dec_refer_count(thr, NULL);
1375 case QUE_THR_COMPLETED:
1376 case QUE_THR_COMMAND_WAIT:
1384 mutex_exit(&kernel_mutex);
1396 ibool reserve_dict_mutex,
1406 if (reserve_dict_mutex) {
1412 if (reserve_dict_mutex) {
1421 graph->
fork_type = QUE_FORK_MYSQL_INTERFACE;
#define UT_LIST_GET_LEN(BASE)
UNIV_INTERN void que_thr_stop_for_mysql_no_error(que_thr_t *thr, trx_t *trx)
#define UT_LIST_GET_NEXT(NAME, N)
UNIV_INTERN que_thr_t * assign_step(que_thr_t *thr)
UNIV_INTERN que_t * pars_sql(pars_info_t *info, const char *str)
UNIV_INTERN void que_run_threads(que_thr_t *thr)
UNIV_INTERN que_thr_t * row_undo_step(que_thr_t *thr)
UNIV_INTERN que_thr_t * if_step(que_thr_t *thr)
#define mem_heap_free(heap)
UNIV_INTERN void que_thr_end_wait(que_thr_t *thr, que_thr_t **next_thr)
UNIV_INTERN que_thr_t * while_step(que_thr_t *thr)
UNIV_INTERN void sel_node_free_private(sel_node_t *node)
UNIV_INTERN void que_fork_error_handle(trx_t *trx, que_t *fork)
UNIV_INLINE ibool que_thr_peek_stop(que_thr_t *thr)
UNIV_INTERN que_node_t * que_node_get_containing_loop_node(que_node_t *node)
UNIV_INTERN que_thr_t * dict_create_index_step(que_thr_t *thr)
UNIV_INLINE void log_free_check(void)
UNIV_INTERN void srv_que_task_enqueue_low(que_thr_t *thr)
UNIV_INLINE que_thr_t * proc_step(que_thr_t *thr)
UNIV_INTERN ibool que_thr_stop(que_thr_t *thr)
UNIV_INTERN que_thr_t * row_purge_step(que_thr_t *thr)
UNIV_INTERN void que_graph_free(que_t *graph)
UNIV_INTERN que_thr_t * dict_create_table_step(que_thr_t *thr)
UNIV_INTERN que_thr_t * trx_commit_step(que_thr_t *thr)
UNIV_INTERN void que_graph_free_recursive(que_node_t *node)
UNIV_INLINE void * mem_heap_alloc(mem_heap_t *heap, ulint n)
UNIV_INTERN ulint que_eval_sql(pars_info_t *info, const char *sql, ibool reserve_dict_mutex, trx_t *trx)
#define UT_LIST_ADD_LAST(NAME, BASE, N)
#define UT_LIST_GET_FIRST(BASE)
UNIV_INTERN void sym_tab_free_private(sym_tab_t *sym_tab)
UNIV_INTERN void que_thr_stop_for_mysql(que_thr_t *thr)
UNIV_INTERN que_thr_t * row_printf_step(que_thr_t *thr)
UNIV_INTERN void srv_suspend_mysql_thread(que_thr_t *thr)
UNIV_INTERN void que_thr_move_to_run_state_for_mysql(que_thr_t *thr, trx_t *trx)
#define UT_LIST_INIT(BASE)
UNIV_INLINE que_node_t * que_node_get_parent(que_node_t *node)
UNIV_INTERN que_thr_t * for_step(que_thr_t *thr)
UNIV_INTERN void trx_end_signal_handling(trx_t *trx)
UNIV_INLINE que_thr_t * proc_eval_step(que_thr_t *thr)
UNIV_INLINE ulint que_node_get_type(que_node_t *node)
UNIV_INTERN que_thr_t * row_upd_step(que_thr_t *thr)
#define UT_LIST_ADD_FIRST(NAME, BASE, N)
UNIV_INLINE que_thr_t * open_step(que_thr_t *thr)
UNIV_INTERN que_thr_t * fetch_step(que_thr_t *thr)
sel_node_t * last_sel_node
UNIV_INTERN que_thr_t * exit_step(que_thr_t *thr)
UNIV_INTERN que_thr_t * return_step(que_thr_t *thr)
UNIV_INLINE trx_t * thr_get_trx(que_thr_t *thr)
UNIV_INTERN que_thr_t * row_ins_step(que_thr_t *thr)
UNIV_INTERN que_thr_t * trx_rollback_step(que_thr_t *thr)
UNIV_INTERN void mem_analyze_corruption(void *ptr)
UNIV_INTERN void trx_finish_rollback_off_kernel(que_t *graph, trx_t *trx, que_thr_t **next_thr)
UNIV_INTERN void trx_sig_start_handle(trx_t *trx, que_thr_t **next_thr)
UNIV_INTERN void btr_pcur_free_for_mysql(btr_pcur_t *cursor)
UNIV_INTERN void pars_info_free(pars_info_t *info)
UNIV_INTERN void srv_release_mysql_thread_if_suspended(que_thr_t *thr)
UNIV_INTERN que_thr_t * que_thr_create(que_fork_t *parent, mem_heap_t *heap)
UNIV_INTERN void que_thr_end_wait_no_next_thr(que_thr_t *thr)
UNIV_INLINE que_node_t * que_node_get_next(que_node_t *node)
UNIV_INTERN que_thr_t * que_fork_start_command(que_fork_t *fork)
UNIV_INTERN void que_graph_publish(que_t *graph, sess_t *sess)
UNIV_INTERN void que_node_print_info(que_node_t *node)
UNIV_INTERN que_thr_t * row_sel_step(que_thr_t *thr)
UNIV_INTERN que_fork_t * que_fork_create(que_t *graph, que_node_t *parent, ulint fork_type, mem_heap_t *heap)