mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 22:12:30 +01:00
branches/zip:
Add the transaction's weight to information_schema.innodb_trx table. Suggested by: Ken Approved by: Heikki
This commit is contained in:
parent
95f1b15a5f
commit
69a8cc07a9
5 changed files with 34 additions and 17 deletions
|
@ -197,7 +197,16 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
|
|||
STRUCT_FLD(old_name, ""),
|
||||
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
|
||||
|
||||
#define IDX_TRX_STATE 1
|
||||
#define IDX_TRX_WEIGHT 1
|
||||
{STRUCT_FLD(field_name, "trx_weight"),
|
||||
STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
|
||||
STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
|
||||
STRUCT_FLD(value, 0),
|
||||
STRUCT_FLD(field_flags, MY_I_S_UNSIGNED),
|
||||
STRUCT_FLD(old_name, ""),
|
||||
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
|
||||
|
||||
#define IDX_TRX_STATE 2
|
||||
{STRUCT_FLD(field_name, "trx_state"),
|
||||
STRUCT_FLD(field_length, TRX_QUE_STATE_STR_MAX_LEN + 1),
|
||||
STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
|
||||
|
@ -206,7 +215,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
|
|||
STRUCT_FLD(old_name, ""),
|
||||
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
|
||||
|
||||
#define IDX_TRX_STARTED 2
|
||||
#define IDX_TRX_STARTED 3
|
||||
{STRUCT_FLD(field_name, "trx_started"),
|
||||
STRUCT_FLD(field_length, 0),
|
||||
STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME),
|
||||
|
@ -215,7 +224,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
|
|||
STRUCT_FLD(old_name, ""),
|
||||
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
|
||||
|
||||
#define IDX_TRX_WAIT_LOCK_ID 3
|
||||
#define IDX_TRX_WAIT_LOCK_ID 4
|
||||
{STRUCT_FLD(field_name, "trx_wait_lock_id"),
|
||||
STRUCT_FLD(field_length, TRX_I_S_LOCK_ID_MAX_LEN),
|
||||
STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
|
||||
|
@ -224,7 +233,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
|
|||
STRUCT_FLD(old_name, ""),
|
||||
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
|
||||
|
||||
#define IDX_TRX_WAIT_STARTED 4
|
||||
#define IDX_TRX_WAIT_STARTED 5
|
||||
{STRUCT_FLD(field_name, "trx_wait_started"),
|
||||
STRUCT_FLD(field_length, 0),
|
||||
STRUCT_FLD(field_type, MYSQL_TYPE_DATETIME),
|
||||
|
@ -233,7 +242,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
|
|||
STRUCT_FLD(old_name, ""),
|
||||
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
|
||||
|
||||
#define IDX_TRX_MYSQL_THREAD_ID 5
|
||||
#define IDX_TRX_MYSQL_THREAD_ID 6
|
||||
{STRUCT_FLD(field_name, "trx_mysql_thread_id"),
|
||||
STRUCT_FLD(field_length, MY_INT64_NUM_DECIMAL_DIGITS),
|
||||
STRUCT_FLD(field_type, MYSQL_TYPE_LONGLONG),
|
||||
|
@ -242,7 +251,7 @@ static ST_FIELD_INFO innodb_trx_fields_info[] =
|
|||
STRUCT_FLD(old_name, ""),
|
||||
STRUCT_FLD(open_method, SKIP_OPEN_TABLE)},
|
||||
|
||||
#define IDX_TRX_QUERY 6
|
||||
#define IDX_TRX_QUERY 7
|
||||
{STRUCT_FLD(field_name, "trx_query"),
|
||||
STRUCT_FLD(field_length, TRX_I_S_TRX_QUERY_MAX_LEN),
|
||||
STRUCT_FLD(field_type, MYSQL_TYPE_STRING),
|
||||
|
@ -290,6 +299,9 @@ fill_innodb_trx_from_cache(
|
|||
/* trx_id */
|
||||
OK(fields[IDX_TRX_ID]->store(row->trx_id));
|
||||
|
||||
/* trx_weight */
|
||||
OK(fields[IDX_TRX_WEIGHT]->store(row->trx_weight));
|
||||
|
||||
/* trx_state */
|
||||
OK(field_store_string(fields[IDX_TRX_STATE],
|
||||
row->trx_state));
|
||||
|
|
|
@ -58,6 +58,7 @@ struct i_s_locks_row_struct {
|
|||
/* This structure represents INFORMATION_SCHEMA.innodb_trx row */
|
||||
typedef struct i_s_trx_row_struct {
|
||||
ullint trx_id;
|
||||
ullint trx_weight;
|
||||
const char* trx_state;
|
||||
ib_time_t trx_started;
|
||||
const i_s_locks_row_t* wait_lock_row;
|
||||
|
|
|
@ -410,10 +410,17 @@ trx_is_interrupted(
|
|||
#endif /* !UNIV_HOTBACKUP */
|
||||
|
||||
/***********************************************************************
|
||||
Compares the "weight" (or size) of two transactions. The weight of one
|
||||
transaction is estimated as the number of altered rows + the number of
|
||||
locked rows. Transactions that have edited non-transactional tables are
|
||||
considered heavier than ones that have not. */
|
||||
Calculates the "weight" of a transaction. The weight of one transaction
|
||||
is estimated as the number of altered rows + the number of locked rows.
|
||||
*/
|
||||
|
||||
#define TRX_WEIGHT(t) \
|
||||
ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
|
||||
|
||||
/***********************************************************************
|
||||
Compares the "weight" (or size) of two transactions. Transactions that
|
||||
have edited non-transactional tables are considered heavier than ones
|
||||
that have not. */
|
||||
|
||||
int
|
||||
trx_weight_cmp(
|
||||
|
|
|
@ -371,6 +371,7 @@ fill_trx_row(
|
|||
strings */
|
||||
{
|
||||
row->trx_id = trx_get_id(trx);
|
||||
row->trx_weight = (ullint) ut_conv_dulint_to_longlong(TRX_WEIGHT(trx));
|
||||
row->trx_started = (ib_time_t) trx->start_time;
|
||||
row->trx_state = trx_get_que_state_str(trx);
|
||||
|
||||
|
|
|
@ -1707,10 +1707,9 @@ trx_print(
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
Compares the "weight" (or size) of two transactions. The weight of one
|
||||
transaction is estimated as the number of altered rows + the number of
|
||||
locked rows. Transactions that have edited non-transactional tables are
|
||||
considered heavier than ones that have not. */
|
||||
Compares the "weight" (or size) of two transactions. Transactions that
|
||||
have edited non-transactional tables are considered heavier than ones
|
||||
that have not. */
|
||||
|
||||
int
|
||||
trx_weight_cmp(
|
||||
|
@ -1755,9 +1754,6 @@ trx_weight_cmp(
|
|||
UT_LIST_GET_LEN(b->trx_locks));
|
||||
#endif
|
||||
|
||||
#define TRX_WEIGHT(t) \
|
||||
ut_dulint_add((t)->undo_no, UT_LIST_GET_LEN((t)->trx_locks))
|
||||
|
||||
return(ut_dulint_cmp(TRX_WEIGHT(a), TRX_WEIGHT(b)));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue