Description:
For tables that normally contain datetime fields, the datetime field data is related to the user's time_zone.
But for information_schema.innodb_trx, the values of the datetime attribute fields (trx_started and trx_wait_started) have nothing to do with the user's time zone, they depend on the system clock.
What's wrong with this? This means that the times in the innodb_trx table for transactions performed by users in different time zones are bound to the system, which is not as expected. At least from the user's point of view, the time of the transaction does not match the actual time (because the recorded time and the actual time are from different time zones).
How to repeat:
Run MTR using follow case:
--echo # 1) Show time_zone;
--echo
SHOW VARIABLES LIKE "time_zone";
SHOW VARIABLES LIKE "system_time_zone";
--echo
--echo # 2) Create table;
--echo
CREATE TABLE t(created_at DATETIME DEFAULT CURRENT_TIMESTAMP);
--echo
--echo # 3) Start transaction in another session.
--echo
--connect (con1, localhost, root, , )
SET session time_zone = "+10:10";
BEGIN;
INSERT INTO test.t VALUES();
SELECT * FROM t;
--echo
--echo # 4) Show trx_started in i_s.innodb_trx;
--echo
--connection default
SELECT trx_started FROM INFORMATION_SCHEMA.INNODB_TRX;
--echo
--echo # 5) Commit and clean
--echo
--connection con1
COMMIT;
--connection default
DROP TABLE t;
Suggested fix:
In my opinion, the record of trx_started and trx_wait_started in innodb_trx should be relevant to the user's time zone, just like `select now()` or `select current_timestamp`.