tidb icon indicating copy to clipboard operation
tidb copied to clipboard

executor: ddl jobs microsecond

Open dveeden opened this issue 10 months ago • 10 comments

What problem does this PR solve?

Issue Number: close #52929

Problem Summary:

What changed and how does it work?

Check List

Tests

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

Side effects

  • [ ] Performance regression: Consumes more CPU
  • [ ] Performance regression: Consumes more Memory
  • [ ] Breaking backward compatibility

Documentation

  • [x] Affects user behaviors
  • [ ] Contains syntax changes
  • [ ] Contains variable changes
  • [ ] Contains experimental features
  • [ ] Changes MySQL compatibility

Release note

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

The time columns in `information_schema.DDL_JOBS` now support microsecond information.

Test

Before:

mysql> SELECT JOB_ID,START_TIME,END_TIME,TIMEDIFF(END_TIME,START_TIME),TIMESTAMPDIFF(MICROSECOND,START_TIME,END_TIME),END_TIME=START_TIME,CONVERT(END_TIME USING utf8mb4) = CONVERT(START_TIME USING utf8mb4) FROM information_schema.DDL_JOBS ORDER BY TIMEDIFF(END_TIME,START_TIME) DESC LIMIT 20;
+--------+---------------------+---------------------+-------------------------------+------------------------------------------------+---------------------+---------------------------------------------------------------------+
| JOB_ID | START_TIME          | END_TIME            | TIMEDIFF(END_TIME,START_TIME) | TIMESTAMPDIFF(MICROSECOND,START_TIME,END_TIME) | END_TIME=START_TIME | CONVERT(END_TIME USING utf8mb4) = CONVERT(START_TIME USING utf8mb4) |
+--------+---------------------+---------------------+-------------------------------+------------------------------------------------+---------------------+---------------------------------------------------------------------+
|  10106 | 2024-04-26 11:20:02 | 2024-04-26 11:20:17 | 00:00:15                      |                                       15102000 |                   0 |                                                                   0 |
|  10108 | 2024-04-26 11:46:50 | 2024-04-26 11:47:05 | 00:00:15                      |                                       15069000 |                   0 |                                                                   0 |
|  10107 | 2024-04-26 11:45:41 | 2024-04-26 11:45:56 | 00:00:14                      |                                       14780000 |                   0 |                                                                   0 |
|   7455 | 2024-04-26 11:13:17 | 2024-04-26 11:13:17 | 00:00:00                      |                                          21000 |                   0 |                                                                   1 |
|   5105 | 2024-04-26 11:12:58 | 2024-04-26 11:12:58 | 00:00:00                      |                                          21000 |                   0 |                                                                   1 |
|   6653 | 2024-04-26 11:13:10 | 2024-04-26 11:13:10 | 00:00:00                      |                                          20000 |                   0 |                                                                   1 |
|   8723 | 2024-04-26 11:13:27 | 2024-04-26 11:13:27 | 00:00:00                      |                                          16000 |                   0 |                                                                   1 |
|   5877 | 2024-04-26 11:13:04 | 2024-04-26 11:13:04 | 00:00:00                      |                                          14000 |                   0 |                                                                   1 |
|   9125 | 2024-04-26 11:13:29 | 2024-04-26 11:13:29 | 00:00:00                      |                                          14000 |                   0 |                                                                   1 |
|   9959 | 2024-04-26 11:13:35 | 2024-04-26 11:13:35 | 00:00:00                      |                                          14000 |                   0 |                                                                   1 |
|   6767 | 2024-04-26 11:13:11 | 2024-04-26 11:13:11 | 00:00:00                      |                                          14000 |                   0 |                                                                   1 |
|   2851 | 2024-04-26 11:12:34 | 2024-04-26 11:12:34 | 00:00:00                      |                                          14000 |                   0 |                                                                   1 |
|   7679 | 2024-04-26 11:13:19 | 2024-04-26 11:13:19 | 00:00:00                      |                                          13000 |                   0 |                                                                   1 |
|   3953 | 2024-04-26 11:12:41 | 2024-04-26 11:12:41 | 00:00:00                      |                                          13000 |                   0 |                                                                   1 |
|   6267 | 2024-04-26 11:13:07 | 2024-04-26 11:13:07 | 00:00:00                      |                                          13000 |                   0 |                                                                   1 |
|   3579 | 2024-04-26 11:12:38 | 2024-04-26 11:12:38 | 00:00:00                      |                                          13000 |                   0 |                                                                   1 |
|   2455 | 2024-04-26 11:12:32 | 2024-04-26 11:12:32 | 00:00:00                      |                                          13000 |                   0 |                                                                   1 |
|   6149 | 2024-04-26 11:13:06 | 2024-04-26 11:13:06 | 00:00:00                      |                                          13000 |                   0 |                                                                   1 |
|   5491 | 2024-04-26 11:13:01 | 2024-04-26 11:13:01 | 00:00:00                      |                                          13000 |                   0 |                                                                   1 |
|   2863 | 2024-04-26 11:12:34 | 2024-04-26 11:12:34 | 00:00:00                      |                                          13000 |                   0 |                                                                   1 |
+--------+---------------------+---------------------+-------------------------------+------------------------------------------------+---------------------+---------------------------------------------------------------------+
20 rows in set (0.12 sec)

After:

mysql> SELECT JOB_ID,START_TIME,END_TIME,TIMEDIFF(END_TIME,START_TIME),TIMESTAMPDIFF(MICROSECOND,START_TIME,END_TIME),END_TIME=START_TIME,CONVERT(END_TIME USING utf8mb4) = CONVERT(START_TIME USING utf8mb4) FROM information_schema.DDL_JOBS ORDER BY TIMEDIFF(END_TIME,START_TIME) DESC LIMIT 20;
+--------+----------------------------+----------------------------+-------------------------------+------------------------------------------------+---------------------+---------------------------------------------------------------------+
| JOB_ID | START_TIME                 | END_TIME                   | TIMEDIFF(END_TIME,START_TIME) | TIMESTAMPDIFF(MICROSECOND,START_TIME,END_TIME) | END_TIME=START_TIME | CONVERT(END_TIME USING utf8mb4) = CONVERT(START_TIME USING utf8mb4) |
+--------+----------------------------+----------------------------+-------------------------------+------------------------------------------------+---------------------+---------------------------------------------------------------------+
|  10106 | 2024-04-26 11:20:02.297000 | 2024-04-26 11:20:17.399000 | 00:00:15                      |                                       15102000 |                   0 |                                                                   0 |
|  10108 | 2024-04-26 11:46:50.526000 | 2024-04-26 11:47:05.595000 | 00:00:15                      |                                       15069000 |                   0 |                                                                   0 |
|  10107 | 2024-04-26 11:45:41.498000 | 2024-04-26 11:45:56.278000 | 00:00:14                      |                                       14780000 |                   0 |                                                                   0 |
|   7455 | 2024-04-26 11:13:17.589000 | 2024-04-26 11:13:17.610000 | 00:00:00                      |                                          21000 |                   0 |                                                                   0 |
|   5105 | 2024-04-26 11:12:58.775000 | 2024-04-26 11:12:58.796000 | 00:00:00                      |                                          21000 |                   0 |                                                                   0 |
|   6653 | 2024-04-26 11:13:10.826000 | 2024-04-26 11:13:10.846000 | 00:00:00                      |                                          20000 |                   0 |                                                                   0 |
|   8723 | 2024-04-26 11:13:27.420000 | 2024-04-26 11:13:27.436000 | 00:00:00                      |                                          16000 |                   0 |                                                                   0 |
|   5877 | 2024-04-26 11:13:04.647000 | 2024-04-26 11:13:04.661000 | 00:00:00                      |                                          14000 |                   0 |                                                                   0 |
|   9125 | 2024-04-26 11:13:29.984000 | 2024-04-26 11:13:29.998000 | 00:00:00                      |                                          14000 |                   0 |                                                                   0 |
|   9959 | 2024-04-26 11:13:35.580000 | 2024-04-26 11:13:35.594000 | 00:00:00                      |                                          14000 |                   0 |                                                                   0 |
|   6767 | 2024-04-26 11:13:11.778000 | 2024-04-26 11:13:11.792000 | 00:00:00                      |                                          14000 |                   0 |                                                                   0 |
|   2851 | 2024-04-26 11:12:34.460000 | 2024-04-26 11:12:34.474000 | 00:00:00                      |                                          14000 |                   0 |                                                                   0 |
|   7679 | 2024-04-26 11:13:19.542000 | 2024-04-26 11:13:19.555000 | 00:00:00                      |                                          13000 |                   0 |                                                                   0 |
|   3953 | 2024-04-26 11:12:41.114000 | 2024-04-26 11:12:41.127000 | 00:00:00                      |                                          13000 |                   0 |                                                                   0 |
|   6267 | 2024-04-26 11:13:07.737000 | 2024-04-26 11:13:07.750000 | 00:00:00                      |                                          13000 |                   0 |                                                                   0 |
|   3579 | 2024-04-26 11:12:38.800000 | 2024-04-26 11:12:38.813000 | 00:00:00                      |                                          13000 |                   0 |                                                                   0 |
|   2455 | 2024-04-26 11:12:32.181000 | 2024-04-26 11:12:32.194000 | 00:00:00                      |                                          13000 |                   0 |                                                                   0 |
|   6149 | 2024-04-26 11:13:06.778000 | 2024-04-26 11:13:06.791000 | 00:00:00                      |                                          13000 |                   0 |                                                                   0 |
|   5491 | 2024-04-26 11:13:01.644000 | 2024-04-26 11:13:01.657000 | 00:00:00                      |                                          13000 |                   0 |                                                                   0 |
|   2863 | 2024-04-26 11:12:34.545000 | 2024-04-26 11:12:34.558000 | 00:00:00                      |                                          13000 |                   0 |                                                                   0 |
+--------+----------------------------+----------------------------+-------------------------------+------------------------------------------------+---------------------+---------------------------------------------------------------------+
20 rows in set (0.14 sec)

dveeden avatar Apr 26 '24 10:04 dveeden

Hi @dveeden. 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/test-infra repository.

tiprow[bot] avatar Apr 26 '24 10:04 tiprow[bot]

/ok-to-test

dveeden avatar Apr 26 '24 10:04 dveeden

The only thing I don't understand is why TIMEDIFF(END_TIME,START_TIME) isn't returning microsecond info

dveeden avatar Apr 26 '24 10:04 dveeden

Also is it possible to create either test for this, maybe an integration test and using --replace_regex to make sure there are a microsecond part?

mjonss avatar Apr 26 '24 11:04 mjonss

LGTM. Are there any risk of breaking existing usage of this table?

Not that I'm aware

dveeden avatar Apr 26 '24 11:04 dveeden

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 74.0201%. Comparing base (3750495) to head (8a3b372).

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #52930        +/-   ##
================================================
+ Coverage   72.4505%   74.0201%   +1.5695%     
================================================
  Files          1493       1493                
  Lines        429363     429363                
================================================
+ Hits         311076     317815      +6739     
+ Misses        99028      91636      -7392     
- Partials      19259      19912       +653     
Flag Coverage Δ
integration 28.2664% <100.0000%> (?)
unit 71.2516% <100.0000%> (-0.0928%) :arrow_down:

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 50.1572% <ø> (+8.7170%) :arrow_up:

codecov[bot] avatar Apr 26 '24 11:04 codecov[bot]

/retest

dveeden avatar Apr 30 '24 06:04 dveeden

/retest

dveeden avatar Apr 30 '24 11:04 dveeden

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mjonss, tangenta

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[bot] avatar May 10 '24 07:05 ti-chi-bot[bot]

[LGTM Timeline notifier]

Timeline:

  • 2024-04-26 11:14:35.736683931 +0000 UTC m=+10229.493819513: :ballot_box_with_check: agreed by mjonss.
  • 2024-05-10 07:11:27.170357594 +0000 UTC m=+1205240.927493160: :ballot_box_with_check: agreed by tangenta.

ti-chi-bot[bot] avatar May 10 '24 07:05 ti-chi-bot[bot]

/retest

dveeden avatar May 10 '24 07:05 dveeden