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

infoschema: add affected_rows to the processlist table #54488

Merged
merged 3 commits into from
Jul 23, 2024

Conversation

ekexium
Copy link
Contributor

@ekexium ekexium commented Jul 8, 2024

What problem does this PR solve?

Issue Number: close #54486

Problem Summary:

We need a straightforward way to know the progress of long-running statements.

What changed and how does it work?

Add a column affected_rows to information_schema.processlist

Check List

Tests

  • Unit test
  • Integration test
  • 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

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

Add a column `CURRENT_AFFECTED_ROWS` to `information_schema.processlist`.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 8, 2024
Copy link

tiprow bot commented Jul 8, 2024

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

@ekexium ekexium force-pushed the feat-processlist-affected-rows branch from 5311adf to d98e730 Compare July 8, 2024 06:51
Copy link

codecov bot commented Jul 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.4427%. Comparing base (08147e7) to head (c093336).
Report is 115 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54488         +/-   ##
=================================================
- Coverage   72.8476%   57.4427%   -15.4049%     
=================================================
  Files          1542       1682        +140     
  Lines        436136     629851     +193715     
=================================================
+ Hits         317715     361804      +44089     
- Misses        98837     244656     +145819     
- Partials      19584      23391       +3807     
Flag Coverage Δ
integration 38.4056% <100.0000%> (?)
unit 72.8142% <100.0000%> (+0.9463%) ⬆️

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

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

@ekexium ekexium force-pushed the feat-processlist-affected-rows branch 2 times, most recently from 2772c86 to 43286ac Compare July 8, 2024 07:28
@ekexium ekexium force-pushed the feat-processlist-affected-rows branch from 43286ac to 52b509b Compare July 8, 2024 08:54
@@ -854,6 +854,7 @@ var tableProcesslistCols = []columnInfo{
{name: "TxnStart", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, deflt: ""},
{name: "RESOURCE_GROUP", tp: mysql.TypeVarchar, size: resourcegroup.MaxGroupNameLength, flag: mysql.NotNullFlag, deflt: ""},
{name: "SESSION_ALIAS", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, deflt: ""},
{name: "AFFECTED_ROWS", tp: mysql.TypeLonglong, size: 21, flag: mysql.UnsignedFlag},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there compatibility risks for tools like dashboard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose they should not depend on the number of the columns...
@lcwangchao have you met any compatibility problems when adding SESSION_ALIAS?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's fine. The added row is in the last position. @bb7133 Could you take a look?

Copy link
Member

@bb7133 bb7133 Jul 17, 2024

Choose a reason for hiding this comment

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

I believe it is fine for compatibility. However, my concern is about the semantics when it is called 'affected rows': all columns in PROCESSLIST are the 'current status' but AFFECTED_ROWS means the affected rows by the last statement, which could be confusing.

For example, after executing INSERT INTO .., we have:

            ID: 2097158
          USER: root
          HOST: 127.0.0.1:50816
            DB: test
       COMMAND: Sleep
          TIME: 16
         STATE: autocommit
          INFO: NULL
        DIGEST: 04fa858fa491c62d194faec2ab427261cc7998b3f1ccf8f6844febca504cb5e9
           MEM: 4096
          DISK: 0
      TxnStart:
RESOURCE_GROUP: default
 SESSION_ALIAS:
 AFFECTED_ROWS: 2
2 rows in set (0.01 sec)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about displaying 0 when INFO is null or len(INFO) == 0?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure, to be honest. Maybe we could also consider renaming it 'AFFECTED_ROWS_LAST_STATEMENT'?

What is the expected result of this column for pipelined DMLs?

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's introduced to reveal the current progress of the statement during its execution, as a pipelined DML may run for a long time. So 'AFFECTED_ROWS_LAST_STATEMENT' is not a good idea I suppose.

Copy link
Contributor

Choose a reason for hiding this comment

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

Or just rename it "CURRENT_AFFECTED_ROWS" to distinguish them and make it clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good

pkg/util/processinfo.go Outdated Show resolved Hide resolved
@@ -854,6 +854,7 @@ var tableProcesslistCols = []columnInfo{
{name: "TxnStart", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, deflt: ""},
{name: "RESOURCE_GROUP", tp: mysql.TypeVarchar, size: resourcegroup.MaxGroupNameLength, flag: mysql.NotNullFlag, deflt: ""},
{name: "SESSION_ALIAS", tp: mysql.TypeVarchar, size: 64, flag: mysql.NotNullFlag, deflt: ""},
{name: "AFFECTED_ROWS", tp: mysql.TypeLonglong, size: 21, flag: mysql.UnsignedFlag},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's fine. The added row is in the last position. @bb7133 Could you take a look?

@ekexium ekexium force-pushed the feat-processlist-affected-rows branch from 4f535ba to c093336 Compare July 18, 2024 02:33
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 18, 2024
@ekexium
Copy link
Contributor Author

ekexium commented Jul 18, 2024

/retest

Copy link

tiprow bot commented Jul 18, 2024

@ekexium: 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-sigs/prow repository.

@ekexium ekexium requested review from tangenta and bb7133 July 23, 2024 02:36
Copy link

ti-chi-bot bot commented Jul 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, 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 ti-chi-bot bot added approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 23, 2024
Copy link

ti-chi-bot bot commented Jul 23, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-18 03:27:36.887129458 +0000 UTC m=+497278.878070919: ☑️ agreed by cfzjywxk.
  • 2024-07-23 02:59:23.185322321 +0000 UTC m=+927585.176263789: ☑️ agreed by tangenta.

Copy link

tiprow bot commented Jul 23, 2024

@ekexium: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow c093336 link true /test fast_test_tiprow
tidb_parser_test c093336 link true /test tidb_parser_test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@ekexium
Copy link
Contributor Author

ekexium commented Jul 23, 2024

/retest

Copy link

tiprow bot commented Jul 23, 2024

@ekexium: 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-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit 15cc6e8 into pingcap:master Jul 23, 2024
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Show affected_rows in information_schema.processlist
5 participants