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

bootstrap: add summary field for system table tidb_background_subtask #46562

Merged
merged 9 commits into from
Sep 4, 2023

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Aug 31, 2023

What problem does this PR solve?

Issue Number: ref #46258

Problem Summary:

We need a field to record the subtask execution statistic(for example, affected row count). Basically, there are three options:

  1. Add a field row_count INTEGER to tidb_background_subtask.
  2. Serialize the row_count in meta BLOB of tidb_background_subtask.
  3. Add a field summary JSON to tidb_background_subtask.

For option 1, it is not extensive to collect more execution statistic. For option 2, it is not convenient to collect the information without deserializing the whole meta blob value.

Option 3 is a better choice since we make json functions GA in TiDB v6.5.0.

Example usage:

mysql> show create table tidb_background_subtask;
+-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table                   | Create Table                                                                                                                                                           |
+-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_background_subtask | CREATE TABLE `tidb_background_subtask` (
  `id` int(11) DEFAULT NULL,
  `summary` json DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin |
+-------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Create subtask:

insert into tidb_background_subtask values (1, '{}');

Update row count:

update tidb_background_subtask set summary= json_set(summary, "$.row_count", "255") where id = 1;

Collect total row count:

mysql> table tidb_background_subtask;
+------+----------------------+
| id   | summary              |
+------+----------------------+
|    1 | {"row_count": "255"} |
|    2 | {"row_count": "2"}   |
|    3 | {"row_count": "3"}   |
+------+----------------------+

mysql> select json_extract(summary, '$.row_count') from tidb_background_subtask;
+---------------------------------------------+
| json_extract(summary, '$.row_count')        |
+---------------------------------------------+
| "255"                                       |
| "2"                                         |
| "3"                                         |
+---------------------------------------------+

mysql> select sum(json_extract(summary, '$.row_count')) from tidb_background_subtask;
+--------------------------------------------------+
| sum(json_extract(summary, '$.row_count'))        |
+--------------------------------------------------+
|                                              260 |
+--------------------------------------------------+
1 row in set (0.01 sec)

What is changed and how it works?

Add a field summary JSON to tidb_background_subtask.

Check List

Tests

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

Side effects

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

Documentation

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

None

@tangenta tangenta requested a review from a team as a code owner August 31, 2023 10:24
@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 Aug 31, 2023
@tiprow
Copy link

tiprow bot commented Aug 31, 2023

Hi @tangenta. 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.

ddl/constant.go Outdated
@@ -65,9 +61,10 @@ const (
state_update_time bigint,
meta longblob,
error BLOB,
execution_info json,
Copy link
Contributor

Choose a reason for hiding this comment

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

prefer name it as summary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@tangenta tangenta changed the title bootstrap: add exec info field for system table tidb_background_subtask [WIP] bootstrap: add exec info field for system table tidb_background_subtask Aug 31, 2023
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 31, 2023
@codecov
Copy link

codecov bot commented Aug 31, 2023

Codecov Report

Merging #46562 (d3db0fb) into master (7e66761) will decrease coverage by 1.0377%.
Report is 20 commits behind head on master.
The diff coverage is 71.4285%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #46562        +/-   ##
================================================
- Coverage   73.3392%   72.3015%   -1.0377%     
================================================
  Files          1309       1332        +23     
  Lines        394535     404958     +10423     
================================================
+ Hits         289349     292791      +3442     
- Misses        86772      93620      +6848     
- Partials      18414      18547       +133     
Flag Coverage Δ
integration 25.7499% <0.0000%> (?)
unit 73.3351% <76.9230%> (-0.0041%) ⬇️

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

Components Coverage Δ
dumpling 54.0444% <ø> (ø)
parser 84.9520% <ø> (-0.0253%) ⬇️
br 47.0848% <ø> (-5.2659%) ⬇️

@tangenta tangenta changed the title [WIP] bootstrap: add exec info field for system table tidb_background_subtask bootstrap: add exec info field for system table tidb_background_subtask Aug 31, 2023
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 31, 2023
@tangenta tangenta changed the title bootstrap: add exec info field for system table tidb_background_subtask bootstrap: add summary field for system table tidb_background_subtask Aug 31, 2023
Copy link
Member

@bb7133 bb7133 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 the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 1, 2023
@@ -80,5 +77,6 @@ const (
start_time bigint,
state_update_time bigint,
meta longblob,
summary json,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why replace ExecutionInfo with summary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is the short term of "subtask execution summary". I think both are fine.

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

ti-chi-bot bot commented Sep 1, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-09-01 02:17:15.047028772 +0000 UTC m=+2066199.596044759: ☑️ agreed by bb7133.
  • 2023-09-01 08:00:10.887731003 +0000 UTC m=+2086775.436746990: ☑️ agreed by wjhuang2016.

@lance6716
Copy link
Contributor

/approve

1 similar comment
@easonn7
Copy link

easonn7 commented Sep 1, 2023

/approve

@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bb7133, easonn7, lance6716, wjhuang2016, ywqzzy

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 Sep 1, 2023
@tangenta
Copy link
Contributor Author

tangenta commented Sep 1, 2023

/retest

@tiprow
Copy link

tiprow bot commented Sep 1, 2023

@tangenta: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@tangenta
Copy link
Contributor Author

tangenta commented Sep 1, 2023

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Sep 1, 2023
@tangenta
Copy link
Contributor Author

tangenta commented Sep 1, 2023

/retest

2 similar comments
@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

/retest

@hawkingrei
Copy link
Member

/test all

@ti-chi-bot ti-chi-bot bot merged commit a427113 into pingcap:master Sep 4, 2023
3 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. 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.

9 participants