Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runaway: change RUNAWAY_WATCHES time type to UTC #54770

Closed
HuSharp opened this issue Jul 19, 2024 · 1 comment · Fixed by #54768 or #56015
Closed

runaway: change RUNAWAY_WATCHES time type to UTC #54770

HuSharp opened this issue Jul 19, 2024 · 1 comment · Fixed by #54768 or #56015

Comments

@HuSharp
Copy link
Contributor

HuSharp commented Jul 19, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Currently tidb_runaway_watch relies on struct QuarantineRecord to store time as UTC, while RUNAWAY_WATCHES directly selects tidb_runaway_watch to convert to local time.

mysql> SELECT * FROM mysql.tidb_runaway_watch limit 1\G
*************************** 1. row ***************************
                 id: 1
resource_group_name: default
         start_time: 2024-07-16 07:34:14.137009
           end_time: 2024-07-16 07:44:14.137009
              watch: 1
         watch_text: select  count(*) from orders where o_orderdate = '1994-11-12'
             source: 127.0.0.1:4000
             action: 3
1 row in set (0.00 sec)

mysql> SELECT * FROM INFORMATION_SCHEMA.RUNAWAY_WATCHES where id =1\G
*************************** 1. row ***************************
                 ID: 1
RESOURCE_GROUP_NAME: default
         START_TIME: 2024-07-16 15:34:14
           END_TIME: 2024-07-16 15:44:14
              WATCH: Exact
         WATCH_TEXT: select  count(*) from orders where o_orderdate = '1994-11-12'
             SOURCE: 127.0.0.1:4000
             ACTION: Kill
1 row in set (0.01 sec)

2. What did you expect to see? (Required)

RUNAWAY_WATCHES displays UTC as well.

3. What did you see instead (Required)

RUNAWAY_WATCHES displays local time while tidb_runaway_watch displays UTC

4. What is your TiDB version? (Required)

master

@HuSharp HuSharp added the type/bug The issue is confirmed as a bug. label Jul 19, 2024
@HuSharp
Copy link
Contributor Author

HuSharp commented Jul 19, 2024

why not change tidb_runaway_watch to local time?
because tidb_runaway_watch is datetime, which is different from timestamp, and can not convert UTC to local time automatically.

CreateRunawayWatchTable = `CREATE TABLE IF NOT EXISTS mysql.tidb_runaway_watch (
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
resource_group_name varchar(32) not null,
start_time datetime(6) NOT NULL,
end_time datetime(6),
watch bigint(10) NOT NULL,
watch_text TEXT NOT NULL,
source varchar(512) NOT NULL,
action bigint(10),
INDEX sql_index(resource_group_name,watch_text(700)) COMMENT "accelerate the speed when select quarantined query",
INDEX time_index(end_time) COMMENT "accelerate the speed when querying with active watch"
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;`

This means the timezone information will be lost, and the user will not know which timezone to switch to when in crossing time zones (the user needs to confirm the local time zone on the server side).

@ti-chi-bot ti-chi-bot bot closed this as completed in 560e92e Jul 23, 2024
@HuSharp HuSharp changed the title runaway: change tidb_runaway_watch time type to UTC runaway: change RUNAWAY_WATCHES time type to UTC Aug 6, 2024
ti-chi-bot bot pushed a commit that referenced this issue Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants