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 to local time #54663

Closed
wants to merge 2 commits into from

Conversation

HuSharp
Copy link
Contributor

@HuSharp HuSharp commented Jul 16, 2024

What problem does this PR solve?

Issue Number: Ref #54434

Problem Summary: runaway: change tidb_runaway_watch to local time

Currently tidb_runaway_watch relies on struct QuarantineRecord to store time as utc, which is not converted to local time when writing to the table, while runaway_watch directly selects tidb_runaway_watch to convert to local time.

It should be changed to: QuarantineRecord keeps utc time, table operations (select/insert/...) represents local time.

What changed and how does it work?

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-16 15:19:34.000000
           end_time: 2024-07-16 15:29:34.000000
              watch: 1
         watch_text: select o_orderdate from orders limit 10000
             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:19:34
           END_TIME: 2024-07-16 15:29:34
              WATCH: Exact
         WATCH_TEXT: select o_orderdate from orders limit 10000
             SOURCE: 127.0.0.1:4000
             ACTION: Kill
1 row in set (0.00 sec)

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

Release note

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

None

Signed-off-by: husharp <ihusharp@gmail.com>
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 16, 2024
Copy link

tiprow bot commented Jul 16, 2024

Hi @HuSharp. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

Signed-off-by: husharp <jinhao.hu@pingcap.com>
Copy link

codecov bot commented Jul 16, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 55.9392%. Comparing base (ce0204a) to head (772e51f).
Report is 36 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54663         +/-   ##
=================================================
- Coverage   72.7038%   55.9392%   -16.7646%     
=================================================
  Files          1551       1672        +121     
  Lines        436702     609395     +172693     
=================================================
+ Hits         317499     340891      +23392     
- Misses        99595     245221     +145626     
- Partials      19608      23283       +3675     
Flag Coverage Δ
integration 37.1276% <18.7500%> (?)
unit 71.7278% <50.0000%> (+0.0163%) ⬆️

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

Components Coverage Δ
dumpling 52.9656% <ø> (ø)
parser ∅ <ø> (∅)
br 52.5709% <ø> (+6.7553%) ⬆️

@HuSharp
Copy link
Contributor Author

HuSharp commented Jul 17, 2024

@JmPotato @nolouch PTAL, thx!

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 17, 2024
Copy link

ti-chi-bot bot commented Jul 19, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: JmPotato, nolouch
Once this PR has been reviewed and has the lgtm label, please assign gmhdbjd for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 19, 2024
Copy link

ti-chi-bot bot commented Jul 19, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-17 08:11:05.795469843 +0000 UTC m=+427887.786411314: ☑️ agreed by JmPotato.
  • 2024-07-19 06:03:24.48576747 +0000 UTC m=+593026.476708939: ☑️ agreed by nolouch.

@nolouch nolouch requested a review from glorv July 19, 2024 06:03
@HuSharp
Copy link
Contributor Author

HuSharp commented Jul 19, 2024

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 19, 2024
@HuSharp
Copy link
Contributor Author

HuSharp commented Jul 19, 2024

replaced by #54768

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

@HuSharp HuSharp closed this Jul 19, 2024
@HuSharp HuSharp deleted the change_runaway_time_zone branch July 19, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants