Commit 7f1ab8f7 authored by Marko Mäkelä's avatar Marko Mäkelä

Cleanups:

que_thr_t::fork_type: Remove.

QUE_THR_SUSPENDED, TRX_QUE_COMMITTING: Remove.

Cleanup lock_cancel_waiting_and_release()
parent ff3f07ce
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2019, 2020, MariaDB Corporation.
Copyright (c) 2019, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -204,7 +204,6 @@ fts_eval_sql(
que_thr_t* thr;
graph->trx = trx;
graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
ut_a(thr = que_fork_start_command(graph));
......
/*****************************************************************************
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2014, 2020, MariaDB Corporation.
Copyright (c) 2014, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -271,7 +271,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
Column("trx_id", ULonglong(), NOT_NULL),
#define IDX_TRX_STATE 1
Column("trx_state", Varchar(TRX_QUE_STATE_STR_MAX_LEN + 1), NOT_NULL),
Column("trx_state", Varchar(13), NOT_NULL),
#define IDX_TRX_STARTED 2
Column("trx_started", Datetime(0), NOT_NULL),
......
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2020, MariaDB Corporation.
Copyright (c) 2017, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -378,8 +378,7 @@ pars_stored_procedure_call(
/*=======================*/
sym_node_t* sym_node); /*!< in: stored procedure name */
/** Completes a query graph by adding query thread and fork nodes
above it and prepares the graph for running. The fork created is of
type QUE_FORK_MYSQL_INTERFACE.
above it and prepares the graph for running.
@param[in] node root node for an incomplete query
graph, or NULL for dummy graph
@param[in] trx transaction handle
......
......@@ -38,15 +38,7 @@ Created 5/27/1996 Heikki Tuuri
/***********************************************************************//**
Creates a query graph fork node.
@return own: fork node */
que_fork_t*
que_fork_create(
/*============*/
que_t* graph, /*!< in: graph, if NULL then this
fork node is assumed to be the
graph root */
que_node_t* parent, /*!< in: parent node */
ulint fork_type, /*!< in: fork type */
mem_heap_t* heap); /*!< in: memory heap where created */
que_fork_t *que_fork_create(mem_heap_t* heap);
/***********************************************************************//**
Gets the first thr in a fork. */
UNIV_INLINE
......@@ -279,8 +271,7 @@ enum que_thr_state_t {
statements, this means the thread has done its task */
QUE_THR_COMPLETED,
QUE_THR_COMMAND_WAIT,
QUE_THR_LOCK_WAIT,
QUE_THR_SUSPENDED
QUE_THR_LOCK_WAIT
};
/** Query thread lock states */
......@@ -356,7 +347,6 @@ struct que_thr_t{
struct que_fork_t{
que_common_t common; /*!< type: QUE_NODE_FORK */
que_t* graph; /*!< query graph of this node */
ulint fork_type; /*!< fork type */
#ifdef UNIV_DEBUG
/** For the query graph root, updated in set_active() */
ulint n_active_thrs;
......@@ -392,15 +382,6 @@ struct que_fork_t{
inline void que_thr_t::set_active(bool active) { graph->set_active(active); };
#endif
/* Query fork (or graph) types */
#define QUE_FORK_ROLLBACK 5
/* This is really the undo graph used in rollback,
no signal-sending roll_node in this graph */
#define QUE_FORK_PURGE 6
#define QUE_FORK_PROCEDURE 8
#define QUE_FORK_MYSQL_INTERFACE 10
#define QUE_FORK_RECOVERY 11
/* Query fork (or graph) states */
#define QUE_FORK_ACTIVE 1
#define QUE_FORK_COMMAND_WAIT 2
......
......@@ -114,8 +114,7 @@ struct i_s_locks_row_t {
/** This structure represents INFORMATION_SCHEMA.innodb_trx row */
struct i_s_trx_row_t {
trx_id_t trx_id; /*!< transaction identifier */
const char* trx_state; /*!< transaction state from
trx_get_que_state_str() */
const char* trx_state;
time_t trx_started; /*!< trx_t::start_time */
const i_s_locks_row_t* requested_lock_row;
/*!< pointer to a row
......
......@@ -328,20 +328,6 @@ is estimated as the number of altered rows + the number of locked rows.
@return transaction weight */
#define TRX_WEIGHT(t) ((t)->undo_no + UT_LIST_GET_LEN((t)->lock.trx_locks))
/* Maximum length of a string that can be returned by
trx_get_que_state_str(). */
#define TRX_QUE_STATE_STR_MAX_LEN 12 /* "ROLLING BACK" */
/*******************************************************************//**
Retrieves transaction's que state in a human readable string. The string
should not be free()'d or modified.
@return string in the data segment */
UNIV_INLINE
const char*
trx_get_que_state_str(
/*==================*/
const trx_t* trx); /*!< in: transaction */
/** Create the trx_t pool */
void
trx_pool_init();
......
......@@ -81,31 +81,6 @@ trx_get_error_info(
return(trx->error_info);
}
/*******************************************************************//**
Retrieves transaction's que state in a human readable string. The string
should not be free()'d or modified.
@return string in the data segment */
UNIV_INLINE
const char*
trx_get_que_state_str(
/*==================*/
const trx_t* trx) /*!< in: transaction */
{
/* be sure to adjust TRX_QUE_STATE_STR_MAX_LEN if you change this */
switch (trx->lock.que_state) {
case TRX_QUE_RUNNING:
return("RUNNING");
case TRX_QUE_LOCK_WAIT:
return("LOCK WAIT");
case TRX_QUE_ROLLING_BACK:
return("ROLLING BACK");
case TRX_QUE_COMMITTING:
return("COMMITTING");
default:
return("UNKNOWN");
}
}
/**********************************************************************//**
Determine if a transaction is a dictionary operation.
@return dictionary operation mode */
......
/*****************************************************************************
Copyright (c) 1996, 2014, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2020, MariaDB Corporation.
Copyright (c) 2017, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -53,8 +53,7 @@ enum trx_que_t {
TRX_QUE_RUNNING, /*!< transaction is running */
TRX_QUE_LOCK_WAIT, /*!< transaction is waiting for
a lock */
TRX_QUE_ROLLING_BACK, /*!< transaction is rolling back */
TRX_QUE_COMMITTING /*!< transaction is committing */
TRX_QUE_ROLLING_BACK /*!< transaction is rolling back */
};
/** Transaction states (trx_t::state) */
......
......@@ -5538,12 +5538,11 @@ lock_cancel_waiting_and_release(
/*============================*/
lock_t* lock) /*!< in/out: waiting lock request */
{
que_thr_t* thr;
lock_sys.mutex_assert_locked();
ut_ad(lock->trx->state == TRX_STATE_ACTIVE);
trx_t* trx = lock->trx;
ut_ad(trx->state == TRX_STATE_ACTIVE);
lock->trx->lock.cancel = true;
trx->lock.cancel = true;
if (lock_get_type_low(lock) == LOCK_REC) {
......@@ -5551,9 +5550,9 @@ lock_cancel_waiting_and_release(
} else {
ut_ad(lock_get_type_low(lock) & LOCK_TABLE);
if (lock->trx->autoinc_locks != NULL) {
if (trx->autoinc_locks) {
/* Release the transaction's AUTOINC locks. */
lock_release_autoinc_locks(lock->trx);
lock_release_autoinc_locks(trx);
}
lock_table_dequeue(lock);
......@@ -5565,15 +5564,11 @@ lock_cancel_waiting_and_release(
lock_reset_lock_and_trx_wait(lock);
/* The following function releases the trx from lock wait. */
thr = que_thr_end_lock_wait(lock->trx);
if (thr != NULL) {
if (que_thr_t *thr = que_thr_end_lock_wait(trx)) {
lock_wait_release_thread_if_suspended(thr);
}
lock->trx->lock.cancel = false;
trx->lock.cancel = false;
}
/*********************************************************************//**
......
/*****************************************************************************
Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2018, 2020, MariaDB Corporation.
Copyright (c) 2018, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -1885,7 +1885,7 @@ pars_procedure_definition(
heap = pars_sym_tab_global->heap;
fork = que_fork_create(NULL, NULL, QUE_FORK_PROCEDURE, heap);
fork = que_fork_create(heap);
fork->trx = NULL;
thr = que_thr_create(fork, heap, NULL);
......@@ -2020,8 +2020,7 @@ pars_sql(
}
/** Completes a query graph by adding query thread and fork nodes
above it and prepares the graph for running. The fork created is of
type QUE_FORK_MYSQL_INTERFACE.
above it and prepares the graph for running.
@param[in] node root node for an incomplete query
graph, or NULL for dummy graph
@param[in] trx transaction handle
......@@ -2038,7 +2037,7 @@ pars_complete_graph_for_exec(
que_fork_t* fork;
que_thr_t* thr;
fork = que_fork_create(NULL, NULL, QUE_FORK_MYSQL_INTERFACE, heap);
fork = que_fork_create(heap);
fork->trx = trx;
thr = que_thr_create(fork, heap, prebuilt);
......
......@@ -90,7 +90,7 @@ The commit or rollback can be seen as a subprocedure call.
When the transaction starts to handle a rollback or commit.
It builds a query graph which, when executed, will roll back
or commit the incomplete transaction. The transaction
is moved to the TRX_QUE_ROLLING_BACK or TRX_QUE_COMMITTING state.
may be moved to the TRX_QUE_ROLLING_BACK state.
If specified, the SQL cursors opened by the transaction are closed.
When the execution of the graph completes, it is like returning
from a subprocedure: the query thread which requested the operation
......@@ -100,14 +100,7 @@ starts running again. */
Creates a query graph fork node.
@return own: fork node */
que_fork_t*
que_fork_create(
/*============*/
que_t* graph, /*!< in: graph, if NULL then this
fork node is assumed to be the
graph root */
que_node_t* parent, /*!< in: parent node */
ulint fork_type, /*!< in: fork type */
mem_heap_t* heap) /*!< in: memory heap where created */
que_fork_create(mem_heap_t *heap)
{
que_fork_t* fork;
......@@ -117,15 +110,11 @@ que_fork_create(
fork->heap = heap;
fork->fork_type = fork_type;
fork->common.parent = parent;
fork->common.type = QUE_NODE_FORK;
fork->state = QUE_FORK_COMMAND_WAIT;
fork->graph = (graph != NULL) ? graph : fork;
fork->graph = fork;
UT_LIST_INIT(fork->thrs, &que_thr_t::thrs);
......@@ -252,7 +241,6 @@ que_fork_scheduler_round_robin(
que_thr_init_command(thr);
break;
case QUE_THR_SUSPENDED:
case QUE_THR_LOCK_WAIT:
default:
ut_error;
......@@ -279,14 +267,12 @@ que_fork_start_command(
que_fork_t* fork) /*!< in: a query fork */
{
que_thr_t* thr;
que_thr_t* suspended_thr = NULL;
que_thr_t* completed_thr = NULL;
fork->state = QUE_FORK_ACTIVE;
fork->last_sel_node = NULL;
suspended_thr = NULL;
completed_thr = NULL;
/* Choose the query thread to run: usually there is just one thread,
......@@ -294,8 +280,7 @@ que_fork_start_command(
there may be several to choose from */
/* First we try to find a query thread in the QUE_THR_COMMAND_WAIT
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. Finally we try to find a query thread in the QUE_THR_COMPLETED
state */
/* We make a single pass over the thr list within which we note which
......@@ -314,16 +299,6 @@ que_fork_start_command(
return(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;
case QUE_THR_COMPLETED:
if (!completed_thr) {
completed_thr = thr;
......@@ -337,10 +312,7 @@ que_fork_start_command(
}
}
if (suspended_thr) {
thr = suspended_thr;
thr->start_running();
} else if (completed_thr) {
if (completed_thr) {
thr = completed_thr;
que_thr_init_command(thr);
} else {
......@@ -618,7 +590,7 @@ que_thr_stop(
if (graph->state == QUE_FORK_COMMAND_WAIT) {
thr->state = QUE_THR_SUSPENDED;
thr->state = QUE_THR_COMMAND_WAIT;
} else if (trx->lock.que_state == TRX_QUE_LOCK_WAIT) {
......@@ -630,10 +602,6 @@ que_thr_stop(
/* Error handling built for the MySQL interface */
thr->state = QUE_THR_COMPLETED;
} else if (graph->fork_type == QUE_FORK_ROLLBACK) {
thr->state = QUE_THR_SUSPENDED;
} else {
ut_ad(graph->state == QUE_FORK_ACTIVE);
......@@ -1096,8 +1064,6 @@ que_eval_sql(
graph->trx = trx;
trx->graph = NULL;
graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
ut_a(thr = que_fork_start_command(graph));
que_run_threads(thr);
......
/*****************************************************************************
Copyright (c) 2012, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2015, 2020, MariaDB Corporation.
Copyright (c) 2015, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -3198,8 +3198,6 @@ row_import_update_index_root(trx_t* trx, dict_table_t* table, bool reset)
que_thr_t* thr;
graph->fork_type = QUE_FORK_MYSQL_INTERFACE;
ut_a(thr = que_fork_start_command(graph));
que_run_threads(thr);
......
......@@ -3609,8 +3609,7 @@ row_log_apply_op(
case ROW_OP_EMPTY:
{
mem_heap_t* heap = mem_heap_create(512);
que_fork_t* fork = que_fork_create(
NULL, NULL, QUE_FORK_MYSQL_INTERFACE, heap);
que_fork_t* fork = que_fork_create(heap);
que_thr_t* thr = que_thr_create(fork, heap, nullptr);
index->clear(thr);
mem_heap_free(heap);
......
......@@ -426,7 +426,21 @@ fill_trx_row(
row->trx_id = trx->id;
row->trx_started = trx->start_time;
row->trx_state = trx_get_que_state_str(trx);
switch (trx->lock.que_state) {
case TRX_QUE_RUNNING:
row->trx_state = trx->state == TRX_STATE_COMMITTED_IN_MEMORY
? "COMMITTING" : "RUNNING";
break;
case TRX_QUE_LOCK_WAIT:
row->trx_state = "LOCK WAIT";
break;
case TRX_QUE_ROLLING_BACK:
row->trx_state = "ROLLING BACK";
break;
default:
row->trx_state = nullptr;
}
row->requested_lock_row = requested_lock_row;
ut_ad(requested_lock_row == NULL
|| i_s_locks_row_validate(requested_lock_row));
......
/*****************************************************************************
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, 2020, MariaDB Corporation.
Copyright (c) 2017, 2021, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
......@@ -148,8 +148,7 @@ purge_graph_build()
trx->op_info = "purge trx";
mem_heap_t* heap = mem_heap_create(512);
que_fork_t* fork = que_fork_create(
NULL, NULL, QUE_FORK_PURGE, heap);
que_fork_t* fork = que_fork_create(heap);
fork->trx = trx;
for (auto i = innodb_purge_threads_MAX; i; i--) {
......
......@@ -604,7 +604,7 @@ trx_rollback_active(
heap = mem_heap_create(512);
fork = que_fork_create(NULL, NULL, QUE_FORK_RECOVERY, heap);
fork = que_fork_create(heap);
fork->trx = trx;
thr = que_thr_create(fork, heap, NULL);
......@@ -871,7 +871,7 @@ trx_roll_graph_build(
que_thr_t* thr;
heap = mem_heap_create(512);
fork = que_fork_create(NULL, NULL, QUE_FORK_ROLLBACK, heap);
fork = que_fork_create(heap);
fork->trx = trx;
thr = que_thr_create(fork, heap, NULL);
......
......@@ -1579,7 +1579,7 @@ trx_commit_or_rollback_prepare(
if (trx->lock.que_state == TRX_QUE_LOCK_WAIT) {
ut_a(trx->lock.wait_thr != NULL);
trx->lock.wait_thr->state = QUE_THR_SUSPENDED;
trx->lock.wait_thr->state = QUE_THR_COMMAND_WAIT;
trx->lock.wait_thr = NULL;
trx->lock.que_state = TRX_QUE_RUNNING;
......@@ -1642,7 +1642,6 @@ trx_commit_step(
trx_commit_or_rollback_prepare(trx);
trx->lock.que_state = TRX_QUE_COMMITTING;
trx->commit();
ut_ad(trx->lock.wait_thr == NULL);
trx->lock.que_state = TRX_QUE_RUNNING;
......@@ -1826,8 +1825,6 @@ trx_print_low(
fputs("LOCK WAIT ", f); break;
case TRX_QUE_ROLLING_BACK:
fputs("ROLLING BACK ", f); break;
case TRX_QUE_COMMITTING:
fputs("COMMITTING ", f); break;
default:
fprintf(f, "que state %lu ", (ulong) trx->lock.que_state);
}
......
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