Commit 76b58c2a authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-24600 performance_schema.events_transactions_history_long.trx_id reports garbage

The table performance_schema.events_transactions_history_long that
was imported from MySQL 5.7.28 in
commit 0ea717f5
may report bogus trx_id values for InnoDB transactions.

innobase_register_trx(): Pass trx->id to trans_register_ha(),
even if it is 0. It is more appropriate to report NULL than some
arbitrary value that has been constructed from the address of a
transaction identifier.
parent d79141d6
#
# MDEV-24600 performance_schema.events_transactions_history_long.trx_id
# reports garbage
#
TRUNCATE performance_schema.events_transactions_history_long;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
COMMIT;
BEGIN;
SELECT table_name FROM mysql.innodb_table_stats LIMIT 0 LOCK IN SHARE MODE;
table_name
COMMIT;
SELECT state,trx_id,gtid
FROM performance_schema.events_transactions_history_long;
state trx_id gtid
COMMITTED NULL 0-0-0
COMMITTED NULL 0-0-0
--source include/not_embedded.inc
--source include/have_perfschema.inc
--source include/have_innodb.inc
--echo #
--echo # MDEV-24600 performance_schema.events_transactions_history_long.trx_id
--echo # reports garbage
--echo #
TRUNCATE performance_schema.events_transactions_history_long;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
COMMIT;
BEGIN;
SELECT table_name FROM mysql.innodb_table_stats LIMIT 0 LOCK IN SHARE MODE;
COMMIT;
SELECT state,trx_id,gtid
FROM performance_schema.events_transactions_history_long;
......@@ -2575,18 +2575,17 @@ innobase_register_trx(
THD* thd, /* in: MySQL thd (connection) object */
trx_t* trx) /* in: transaction to register */
{
const ulonglong trx_id = static_cast<ulonglong>(
trx_get_id_for_print(trx));
ut_ad(!trx->active_commit_ordered);
const trx_id_t trx_id= trx->id;
trans_register_ha(thd, FALSE, hton, trx_id);
trans_register_ha(thd, false, hton, trx_id);
if (!trx_is_registered_for_2pc(trx)
&& thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
trans_register_ha(thd, TRUE, hton, trx_id);
}
trx_register_for_2pc(trx);
if (!trx->is_registered)
{
trx->is_registered= true;
if (thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
trans_register_ha(thd, true, hton, trx_id);
}
}
/* BACKGROUND INFO: HOW THE MYSQL QUERY CACHE WORKS WITH INNODB
......
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