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) #54835

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-8.1 This PR is cherry-picked to release-8.1 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 <[email protected]>
@HuSharp HuSharp force-pushed the cherry-pick-54768-to-release-8.1 branch from 1a88cde to fb93b23 Compare July 23, 2024 08:42
@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 23, 2024
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (release-8.1@42b624c). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.1     #54835   +/-   ##
================================================
  Coverage               ?   72.5207%           
================================================
  Files                  ?       1466           
  Lines                  ?     435037           
  Branches               ?          0           
================================================
  Hits                   ?     315492           
  Misses                 ?      99106           
  Partials               ?      20439           
Flag Coverage Δ
unit 72.5207% <100.0000%> (?)

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

Components Coverage Δ
dumpling 57.8032% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 41.0574% <0.0000%> (?)

@HuSharp
Copy link
Contributor

HuSharp commented Jul 25, 2024

/retest-required

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 25, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jul 31, 2024
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

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 approved 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

[LGTM Timeline notifier]

Timeline:

  • 2024-07-25 06:49:34.210816177 +0000 UTC m=+1114196.201757647: ☑️ agreed by JmPotato.
  • 2024-08-05 03:05:21.867271529 +0000 UTC m=+234851.734370617: ☑️ agreed by GMHDBJD.

@HuSharp
Copy link
Contributor

HuSharp commented Aug 5, 2024

/test mysql-test

Copy link

tiprow bot commented Aug 5, 2024

@HuSharp: No presubmit jobs available for pingcap/[email protected]

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 5, 2024

/test mysql-test

Copy link

tiprow bot commented Aug 5, 2024

@HuSharp: No presubmit jobs available for pingcap/[email protected]

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 5, 2024

/test mysql-test

Copy link

tiprow bot commented Aug 5, 2024

@HuSharp: No presubmit jobs available for pingcap/[email protected]

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 5, 2024

/test mysql-test

Copy link

tiprow bot commented Aug 5, 2024

@HuSharp: No presubmit jobs available for pingcap/[email protected]

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 5, 2024

/test check-dev2

Copy link

tiprow bot commented Aug 5, 2024

@HuSharp: No presubmit jobs available for pingcap/[email protected]

In response to this:

/test check-dev2

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 5, 2024

/test check-dev2

Copy link

tiprow bot commented Aug 5, 2024

@HuSharp: No presubmit jobs available for pingcap/[email protected]

In response to this:

/test check-dev2

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 abee658 into pingcap:release-8.1 Aug 5, 2024
18 checks passed
@HuSharp HuSharp deleted the cherry-pick-54768-to-release-8.1 branch August 5, 2024 12:50
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-8.1 This PR is cherry-picked to release-8.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants