Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
bd65e80c
Commit
bd65e80c
authored
May 12, 2010
by
Jimmy Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check in patch for bug #53336, Improved InnoDB Transaction Reporting.
rb://335
, Approved by Sunny Bains
parent
9451ee4b
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
598 additions
and
34 deletions
+598
-34
mysql-test/suite/innodb/r/innodb_information_schema.result
mysql-test/suite/innodb/r/innodb_information_schema.result
+43
-0
mysql-test/suite/innodb/t/innodb_information_schema.test
mysql-test/suite/innodb/t/innodb_information_schema.test
+103
-0
storage/innobase/handler/i_s.cc
storage/innobase/handler/i_s.cc
+308
-0
storage/innobase/include/lock0lock.h
storage/innobase/include/lock0lock.h
+1
-1
storage/innobase/include/trx0i_s.h
storage/innobase/include/trx0i_s.h
+73
-14
storage/innobase/lock/lock0lock.c
storage/innobase/lock/lock0lock.c
+1
-1
storage/innobase/trx/trx0i_s.c
storage/innobase/trx/trx0i_s.c
+69
-18
No files found.
mysql-test/suite/innodb/r/innodb_information_schema.result
View file @
bd65e80c
...
...
@@ -21,3 +21,46 @@ lock_table COUNT(*)
"test"."t_max" 2
"test"."t_min" 2
"test"."`t'\""_str" 10
Field Type Null Key Default Extra
trx_id varchar(18) NO
trx_state varchar(13) NO
trx_started datetime NO 0000-00-00 00:00:00
trx_requested_lock_id varchar(81) YES NULL
trx_wait_started datetime YES NULL
trx_weight bigint(21) unsigned NO 0
trx_mysql_thread_id bigint(21) unsigned NO 0
trx_query varchar(1024) YES NULL
trx_operation_state varchar(64) YES NULL
trx_tables_in_use bigint(21) unsigned NO 0
trx_tables_locked bigint(21) unsigned NO 0
trx_lock_structs bigint(21) unsigned NO 0
trx_lock_memory_bytes bigint(21) unsigned NO 0
trx_rows_locked bigint(21) unsigned NO 0
trx_rows_modified bigint(21) unsigned NO 0
trx_concurrency_tickets bigint(21) unsigned NO 0
trx_isolation_level varchar(16) NO
trx_unique_checks int(1) NO 0
trx_foreign_key_checks int(1) NO 0
trx_last_foreign_key_error varchar(256) YES NULL
trx_apative_hash_latched int(1) NO 0
trx_adaptive_hash_timeout bigint(21) unsigned NO 0
trx_operation_state varchar(64) YES NULL
trx_tables_in_use bigint(21) unsigned NO 0
trx_tables_locked bigint(21) unsigned NO 0
trx_lock_structs bigint(21) unsigned NO 0
trx_lock_memory_bytes bigint(21) unsigned NO 0
trx_rows_locked bigint(21) unsigned NO 0
trx_rows_modified bigint(21) unsigned NO 0
trx_concurrency_tickets bigint(21) unsigned NO 0
trx_isolation_level varchar(16) NO
trx_unique_checks int(1) NO 0
trx_foreign_key_checks int(1) NO 0
trx_last_foreign_key_error varchar(256) YES NULL
trx_apative_hash_latched int(1) NO 0
trx_adaptive_hash_timeout bigint(21) unsigned NO 0
trx_state trx_weight trx_tables_in_use trx_tables_locked trx_rows_locked trx_rows_modified trx_concurrency_tickets trx_isolation_level trx_unique_checks trx_foreign_key_checks
RUNNING 4 0 0 7 1 0 REPEATABLE READ 1 1
trx_isolation_level trx_unique_checks trx_foreign_key_checks
SERIALIZABLE 0 0
trx_state trx_isolation_level trx_last_foreign_key_error
RUNNING SERIALIZABLE `test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`)
mysql-test/suite/innodb/t/innodb_information_schema.test
View file @
bd65e80c
...
...
@@ -64,6 +64,8 @@ INSERT INTO ```t'\"_str` VALUES
INSERT
INTO
```t'\"_str`
VALUES
(
'4'
,
'abc'
,
0x00616263
,
0x61626300
,
0x61006263
,
0x6100626300
,
0x610062630000
);
--
source
include
/
count_sessions
.
inc
--
connect
(
con_lock
,
localhost
,
root
,,)
--
connect
(
con_min_trylock
,
localhost
,
root
,,)
--
connect
(
con_max_trylock
,
localhost
,
root
,,)
...
...
@@ -147,3 +149,104 @@ SET @@sql_mode=@save_sql_mode;
--
disconnect
con_verify_innodb_locks
DROP
TABLE
t_min
,
t_max
,
```t'\"_str`
;
--
source
include
/
wait_until_count_sessions
.
inc
#
# Test that transaction data is correctly "visualized" in
# INFORMATION_SCHEMA.INNODB_TRX
#
--
enable_result_log
DESCRIBE
INFORMATION_SCHEMA
.
INNODB_TRX
;
--
disable_result_log
--
disable_warnings
DROP
TABLE
IF
EXISTS
t1
;
--
enable_warnings
CREATE
TABLE
t1
(
c01
INT
,
c02
INT
,
PRIMARY
KEY
(
c01
)
)
ENGINE
=
InnoDB
;
INSERT
INTO
t1
VALUES
(
1
,
2
),(
2
,
4
),(
3
,
6
),(
4
,
8
);
CREATE
TABLE
t2
(
c01
INT
,
c02
INT
,
PRIMARY
KEY
(
c01
),
FOREIGN
KEY
fk1
(
c02
)
REFERENCES
t1
(
c01
)
)
ENGINE
=
InnoDB
;
INSERT
INTO
t2
VALUES
(
1
,
1
),(
2
,
2
),(
3
,
3
);
--
connect
(
con_trx
,
localhost
,
root
,,)
--
connect
(
con_verify_innodb_trx
,
localhost
,
root
,,)
--
connection
con_trx
SET
autocommit
=
0
;
INSERT
INTO
t1
VALUES
(
5
,
10
);
SELECT
*
FROM
t1
FOR
UPDATE
;
let
$wait_condition
=
SELECT
COUNT
(
*
)
=
1
FROM
INFORMATION_SCHEMA
.
INNODB_TRX
;
--
source
include
/
wait_condition
.
inc
--
disable_query_log
--
connection
con_verify_innodb_trx
--
enable_result_log
SELECT
trx_state
,
trx_weight
,
trx_tables_in_use
,
trx_tables_locked
,
trx_rows_locked
,
trx_rows_modified
,
trx_concurrency_tickets
,
trx_isolation_level
,
trx_unique_checks
,
trx_foreign_key_checks
FROM
INFORMATION_SCHEMA
.
INNODB_TRX
;
--
connection
con_trx
--
disable_result_log
ROLLBACK
;
SET
FOREIGN_KEY_CHECKS
=
0
;
SET
UNIQUE_CHECKS
=
0
;
SET
TRANSACTION
ISOLATION
LEVEL
SERIALIZABLE
;
BEGIN
;
INSERT
INTO
t1
VALUES
(
6
,
12
);
let
$wait_condition
=
SELECT
trx_unique_checks
=
0
FROM
INFORMATION_SCHEMA
.
INNODB_TRX
;
--
source
include
/
wait_condition
.
inc
--
disable_query_log
--
connection
con_verify_innodb_trx
--
enable_result_log
SELECT
trx_isolation_level
,
trx_unique_checks
,
trx_foreign_key_checks
FROM
INFORMATION_SCHEMA
.
INNODB_TRX
;
--
disable_result_log
--
connection
con_trx
ROLLBACK
;
SET
FOREIGN_KEY_CHECKS
=
1
;
SET
UNIQUE_CHECKS
=
1
;
BEGIN
;
--
error
1452
INSERT
INTO
t2
VALUES
(
4
,
10
);
let
$wait_condition
=
SELECT
trx_unique_checks
=
1
FROM
INFORMATION_SCHEMA
.
INNODB_TRX
;
--
source
include
/
wait_condition
.
inc
--
disable_query_log
--
enable_result_log
--
connection
con_verify_innodb_trx
SELECT
trx_state
,
trx_isolation_level
,
trx_last_foreign_key_error
FROM
INFORMATION_SCHEMA
.
INNODB_TRX
;
--
disable_result_log
--
connection
default
--
disconnect
con_trx
--
disconnect
con_verify_innodb_trx
DROP
TABLE
t2
;
DROP
TABLE
t1
;
storage/innobase/handler/i_s.cc
View file @
bd65e80c
This diff is collapsed.
Click to expand it.
storage/innobase/include/lock0lock.h
View file @
bd65e80c
...
...
@@ -637,7 +637,7 @@ UNIV_INTERN
ulint
lock_number_of_rows_locked
(
/*=======================*/
trx_t
*
trx
);
/*!< in: transaction */
const
trx_t
*
trx
);
/*!< in: transaction */
/*******************************************************************//**
Check if a transaction holds any autoinc locks.
@return TRUE if the transaction holds any AUTOINC locks. */
...
...
storage/innobase/include/trx0i_s.h
View file @
bd65e80c
...
...
@@ -44,6 +44,37 @@ i_s_locks_row_t::lock_data */
i_s_trx_row_t::trx_query */
#define TRX_I_S_TRX_QUERY_MAX_LEN 1024
/** The maximum length of a string that can be stored in
i_s_trx_row_t::trx_operation_state */
#define TRX_I_S_TRX_OP_STATE_MAX_LEN 64
/** The maximum length of a string that can be stored in
i_s_trx_row_t::trx_foreign_key_error */
#define TRX_I_S_TRX_FK_ERROR_MAX_LEN 256
/** The maximum length of a string that can be stored in
i_s_trx_row_t::trx_isolation_level */
#define TRX_I_S_TRX_ISOLATION_LEVEL_MAX_LEN 16
/** Safely copy strings in to the INNODB_TRX table's
string based columns */
#define TRX_I_S_STRING_COPY(data, field, constraint, tcache) \
do { \
if (strlen(data) > constraint) { \
char buff[constraint + 1]; \
strncpy(buff, data, constraint); \
buff[constraint] = '\0'; \
\
field = ha_storage_put_memlim( \
(tcache)->storage, buff, constraint + 1,\
MAX_ALLOWED_FOR_STORAGE(tcache)); \
} else { \
field = ha_storage_put_str_memlim( \
(tcache)->storage, data, \
MAX_ALLOWED_FOR_STORAGE(tcache)); \
} \
} while (0)
/** A row of INFORMATION_SCHEMA.innodb_locks */
typedef
struct
i_s_locks_row_struct
i_s_locks_row_t
;
/** A row of INFORMATION_SCHEMA.innodb_trx */
...
...
@@ -95,21 +126,49 @@ struct i_s_locks_row_struct {
/** This structure represents INFORMATION_SCHEMA.innodb_trx row */
struct
i_s_trx_row_struct
{
ullint
trx_id
;
/*!< transaction identifier */
const
char
*
trx_state
;
/*!< transaction state from
trx_get_que_state_str() */
ib_time_t
trx_started
;
/*!< trx_struct::start_time */
ullint
trx_id
;
/*!< transaction identifier */
const
char
*
trx_state
;
/*!< transaction state from
trx_get_que_state_str() */
ib_time_t
trx_started
;
/*!< trx_struct::start_time */
const
i_s_locks_row_t
*
requested_lock_row
;
/*!< pointer to a row
in innodb_locks if trx
is waiting, or NULL */
ib_time_t
trx_wait_started
;
/*!< trx_struct::wait_started */
ullint
trx_weight
;
/*!< TRX_WEIGHT() */
ulint
trx_mysql_thread_id
;
/*!< thd_get_thread_id() */
const
char
*
trx_query
;
/*!< MySQL statement being
executed in the transaction */
/*!< pointer to a row
in innodb_locks if trx
is waiting, or NULL */
ib_time_t
trx_wait_started
;
/*!< trx_struct::wait_started */
ullint
trx_weight
;
/*!< TRX_WEIGHT() */
ulint
trx_mysql_thread_id
;
/*!< thd_get_thread_id() */
const
char
*
trx_query
;
/*!< MySQL statement being
executed in the transaction */
const
char
*
trx_operation_state
;
/*!< trx_struct::op_info */
ulint
trx_tables_in_use
;
/*!< n_mysql_tables_in_use in
trx_struct */
ulint
trx_tables_locked
;
/*!< mysql_n_tables_locked in
trx_struct */
ulint
trx_lock_structs
;
/*!< list len of trx_locks in
trx_struct */
ulint
trx_lock_memory_bytes
;
/*!< mem_heap_get_size(
trx->lock_heap) */
ulint
trx_rows_locked
;
/*!< lock_number_of_rows_locked() */
ullint
trx_rows_modified
;
/*!< trx_struct::undo_no */
ulint
trx_concurrency_tickets
;
/*!< n_tickets_to_enter_innodb in
trx_struct */
const
char
*
trx_isolation_level
;
/*!< isolation_level in trx_struct*/
ibool
trx_unique_checks
;
/*!< check_unique_secondary in
trx_struct*/
ibool
trx_foreign_key_checks
;
/*!< check_foreigns in trx_struct */
const
char
*
trx_foreign_key_error
;
/*!< detailed_error in trx_struct */
ibool
trx_has_search_latch
;
/*!< has_search_latch in trx_struct */
ulint
trx_search_latch_timeout
;
/*!< search_latch_timeout in
trx_struct */
};
/** This structure represents INFORMATION_SCHEMA.innodb_lock_waits row */
...
...
storage/innobase/lock/lock0lock.c
View file @
bd65e80c
...
...
@@ -1624,7 +1624,7 @@ UNIV_INTERN
ulint
lock_number_of_rows_locked
(
/*=======================*/
trx_t
*
trx
)
/*!< in: transaction */
const
trx_t
*
trx
)
/*!< in: transaction */
{
lock_t
*
lock
;
ulint
n_records
=
0
;
...
...
storage/innobase/trx/trx0i_s.c
View file @
bd65e80c
...
...
@@ -427,7 +427,7 @@ fill_trx_row(
/*=========*/
i_s_trx_row_t
*
row
,
/*!< out: result object
that's filled */
const
trx_t
*
trx
,
/*!< in: transaction to
const
trx_t
*
trx
,
/*!< in: transaction to
get data from */
const
i_s_locks_row_t
*
requested_lock_row
,
/*!< in: pointer to the
corresponding row in
...
...
@@ -470,35 +470,86 @@ fill_trx_row(
if
(
trx
->
mysql_query_str
!=
NULL
&&
*
trx
->
mysql_query_str
!=
NULL
)
{
if
(
strlen
(
*
trx
->
mysql_query_str
)
>
TRX_I_S_TRX_QUERY_MAX_LEN
)
{
TRX_I_S_STRING_COPY
(
*
trx
->
mysql_query_str
,
row
->
trx_query
,
TRX_I_S_TRX_QUERY_MAX_LEN
,
cache
);
char
query
[
TRX_I_S_TRX_QUERY_MAX_LEN
+
1
];
if
(
row
->
trx_query
==
NULL
)
{
memcpy
(
query
,
*
trx
->
mysql_query_str
,
TRX_I_S_TRX_QUERY_MAX_LEN
);
query
[
TRX_I_S_TRX_QUERY_MAX_LEN
]
=
'\0'
;
return
(
FALSE
);
}
}
else
{
row
->
trx_query
=
ha_storage_put_memlim
(
cache
->
storage
,
query
,
TRX_I_S_TRX_QUERY_MAX_LEN
+
1
,
MAX_ALLOWED_FOR_STORAGE
(
cache
));
}
else
{
row
->
trx_query
=
NULL
;
}
row
->
trx_query
=
ha_storage_put_str_memlim
(
cache
->
storage
,
*
trx
->
mysql_query_str
,
MAX_ALLOWED_FOR_STORAGE
(
cache
));
}
if
(
trx
->
op_info
!=
NULL
&&
trx
->
op_info
[
0
]
!=
'\0'
)
{
if
(
row
->
trx_query
==
NULL
)
{
TRX_I_S_STRING_COPY
(
trx
->
op_info
,
row
->
trx_operation_state
,
TRX_I_S_TRX_OP_STATE_MAX_LEN
,
cache
);
if
(
row
->
trx_operation_state
==
NULL
)
{
return
(
FALSE
);
}
}
else
{
row
->
trx_
query
=
NULL
;
row
->
trx_
operation_state
=
NULL
;
}
row
->
trx_tables_in_use
=
trx
->
n_mysql_tables_in_use
;
row
->
trx_tables_locked
=
trx
->
mysql_n_tables_locked
;
row
->
trx_lock_structs
=
UT_LIST_GET_LEN
(
trx
->
trx_locks
);
row
->
trx_lock_memory_bytes
=
mem_heap_get_size
(
trx
->
lock_heap
);
row
->
trx_rows_locked
=
lock_number_of_rows_locked
(
trx
);
row
->
trx_rows_modified
=
ut_conv_dulint_to_longlong
(
trx
->
undo_no
);
row
->
trx_concurrency_tickets
=
trx
->
n_tickets_to_enter_innodb
;
switch
(
trx
->
isolation_level
)
{
case
TRX_ISO_READ_UNCOMMITTED
:
row
->
trx_isolation_level
=
"READ UNCOMMITTED"
;
break
;
case
TRX_ISO_READ_COMMITTED
:
row
->
trx_isolation_level
=
"READ COMMITTED"
;
break
;
case
TRX_ISO_REPEATABLE_READ
:
row
->
trx_isolation_level
=
"REPEATABLE READ"
;
break
;
case
TRX_ISO_SERIALIZABLE
:
row
->
trx_isolation_level
=
"SERIALIZABLE"
;
break
;
/* Should not happen as TRX_ISO_READ_COMMITTED is default */
default:
row
->
trx_isolation_level
=
"UNKNOWN"
;
}
row
->
trx_unique_checks
=
(
ibool
)
trx
->
check_unique_secondary
;
row
->
trx_foreign_key_checks
=
(
ibool
)
trx
->
check_foreigns
;
if
(
trx
->
detailed_error
!=
NULL
&&
trx
->
detailed_error
[
0
]
!=
'\0'
)
{
TRX_I_S_STRING_COPY
(
trx
->
detailed_error
,
row
->
trx_foreign_key_error
,
TRX_I_S_TRX_FK_ERROR_MAX_LEN
,
cache
);
if
(
row
->
trx_foreign_key_error
==
NULL
)
{
return
(
FALSE
);
}
}
else
{
row
->
trx_foreign_key_error
=
NULL
;
}
row
->
trx_has_search_latch
=
(
ibool
)
trx
->
has_search_latch
;
row
->
trx_search_latch_timeout
=
trx
->
search_latch_timeout
;
return
(
TRUE
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment