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 tidb_runaway_watch time type to UTC (#54768) #54834

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #54768

What problem does this PR solve?

Issue Number: Close #54770, Ref #54434

Problem Summary: runaway: change tidb_runaway_watch to UTC

What changed and how does it work?

Currently tidb_runaway_watch relies on struct QuarantineRecord to store time as UTC, while runaway_watch directly selects tidb_runaway_watch to convert to local time. Let's change tidb_runaway_watch to UTC as well.

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).

before

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)

After

mysql> SELECT * FROM mysql.tidb_runaway_watch limit 1\G
*************************** 1. row ***************************
                 id: 1
resource_group_name: default
         start_time: 2024-07-19 07:18:36.572748
           end_time: 2024-07-19 07:28:36.572748
              watch: 1
         watch_text: select  count(*) from orders where o_orderdate = '1992-07-03'
             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-19 07:18:36
           END_TIME: 2024-07-19 07:28:36
              WATCH: Exact
         WATCH_TEXT: select  count(*) from orders where o_orderdate = '1992-07-03'
             SOURCE: 127.0.0.1:4000
             ACTION: Kill
1 row in set (0.00 sec)

Check List

Tests

  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

runaway: change tidb_runaway_watch time type to UTC

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels Jul 23, 2024
@ti-chi-bot ti-chi-bot bot added do-not-merge/cherry-pick-not-approved size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 23, 2024
Signed-off-by: husharp <jinhao.hu@pingcap.com>
@HuSharp HuSharp force-pushed the cherry-pick-54768-to-release-7.5 branch from 70e8bc4 to 1f7ed37 Compare July 25, 2024 06:27
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 25, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 25, 2024
Copy link

codecov bot commented Jul 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-7.5@1cd80eb). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-7.5     #54834   +/-   ##
================================================
  Coverage               ?   71.9998%           
================================================
  Files                  ?       1413           
  Lines                  ?     411634           
  Branches               ?          0           
================================================
  Hits                   ?     296376           
  Misses                 ?      95362           
  Partials               ?      19896           
Flag Coverage Δ
unit 71.9998% <100.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9400% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 53.5154% <0.0000%> (?)

@HuSharp
Copy link
Contributor

HuSharp commented Jul 25, 2024

/retest-required

Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 5, 2024
Copy link

ti-chi-bot bot commented Aug 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, JmPotato

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Aug 5, 2024
Copy link

ti-chi-bot bot commented Aug 5, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-25 06:49:50.148184879 +0000 UTC m=+1114212.139126348: ☑️ agreed by JmPotato.
  • 2024-08-05 03:07:02.508685625 +0000 UTC m=+234952.375784713: ☑️ agreed by GMHDBJD.

@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Aug 5, 2024
@HuSharp
Copy link
Contributor

HuSharp commented Aug 7, 2024

/test mysql-test

Copy link

tiprow bot commented Aug 7, 2024

@HuSharp: No presubmit jobs available for pingcap/tidb@release-7.5

In response to this:

/test mysql-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@HuSharp
Copy link
Contributor

HuSharp commented Aug 7, 2024

/test unit-test

Copy link

tiprow bot commented Aug 7, 2024

@HuSharp: No presubmit jobs available for pingcap/tidb@release-7.5

In response to this:

/test unit-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit 01b4f05 into pingcap:release-7.5 Aug 7, 2024
18 checks passed
@HuSharp HuSharp deleted the cherry-pick-54768-to-release-7.5 branch September 3, 2024 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants