Skip to content

Conversation

CbcWestwolf
Copy link
Member

@CbcWestwolf CbcWestwolf commented Apr 28, 2025

What problem does this PR solve?

Issue Number: close #60925

Problem Summary:

See the description in the issue.

What changed and how does it work?

We can utilize the common metric in pkg/lightning to get the total writing size

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.
  1. tiup playground --db.binpath=./bin/tidb-server --db 2 --kv 4
  2. prepare data: sysbench oltp_read_write prepare --mysql-host=127.0.0.1 --mysql-port=4000 --mysql-user=root --mysql-db=test --table-size=100000000
  3. alter table sbtest1 add index i(k, c, pad) using different adding index ways and write speed
admin show ddl jobs where job_type = 'add index';
+--------+---------+------------+-----------+--------------+-----------+----------+-----------+----------------------------+----------------------------+----------------------------+--------+-----------------------------------------------------------------+
| JOB_ID | DB_NAME | TABLE_NAME | JOB_TYPE  | SCHEMA_STATE | SCHEMA_ID | TABLE_ID | ROW_COUNT | CREATE_TIME                | START_TIME                 | END_TIME                   | STATE  | COMMENTS                                                        |
+--------+---------+------------+-----------+--------------+-----------+----------+-----------+----------------------------+----------------------------+----------------------------+--------+-----------------------------------------------------------------+
|    123 | test    | sbtest1    | add index | public       |         2 |      112 | 100000000 | 2025-04-28 23:12:15.904000 | 2025-04-28 23:12:15.904000 | 2025-04-28 23:23:27.054000 | synced | ingest, max_write_speed=41943040, max_node_count=3              |
|    121 | test    | sbtest1    | add index | public       |         2 |      112 | 100000000 | 2025-04-28 23:05:16.405000 | 2025-04-28 23:05:16.455000 | 2025-04-28 23:11:37.205000 | synced | ingest, max_write_speed=104857600, max_node_count=3             |
|    119 | test    | sbtest1    | add index | public       |         2 |      112 | 100000000 | 2025-04-28 23:00:31.805000 | 2025-04-28 23:00:31.805000 | 2025-04-28 23:03:58.655000 | synced | ingest, DXF, cloud, max_write_speed=104857600, max_node_count=3 |
|    117 | test    | sbtest1    | add index | public       |         2 |      112 | 100000000 | 2025-04-28 22:52:54.754000 | 2025-04-28 22:52:54.754000 | 2025-04-28 22:57:58.555000 | synced | ingest, DXF, max_write_speed=104857600, max_node_count=3        |
image image

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

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 28, 2025
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 28, 2025
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

Attention: Patch coverage is 13.15789% with 33 lines in your changes missing coverage. Please review.

Project coverage is 74.6163%. Comparing base (e8fb24a) to head (b52d8bc).
Report is 452 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #60904        +/-   ##
================================================
+ Coverage   73.1316%   74.6163%   +1.4846%     
================================================
  Files          1719       1768        +49     
  Lines        476215     488790     +12575     
================================================
+ Hits         348264     364717     +16453     
+ Misses       106583     101188      -5395     
- Partials      21368      22885      +1517     
Flag Coverage Δ
integration 48.7142% <14.7058%> (?)
unit 72.3369% <13.1578%> (-0.0144%) ⬇️

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

Components Coverage Δ
dumpling 52.7804% <ø> (+0.0685%) ⬆️
parser ∅ <ø> (∅)
br 61.4002% <ø> (+14.0459%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CbcWestwolf CbcWestwolf changed the title metrics: add some metrics for adding index metrics: add import speed metric for adding index Apr 29, 2025
Co-authored-by: tangenta <tangenta@126.com>
@@ -86,6 +95,10 @@ var (
AddIndexScanRate *prometheus.HistogramVec
)

func init() {
registeredJob = make(map[int64]*metric.Common, 64)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a check to CheckIngestLeakageForTest to ensure the metrics are unregistered?

@D3Hunter D3Hunter changed the title metrics: add import speed metric for adding index addindex: add import speed metric Apr 29, 2025
@CbcWestwolf
Copy link
Member Author

/retest

@CbcWestwolf
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Apr 30, 2025
@@ -61,6 +62,8 @@ type readIndexStepExecutor struct {
backend *local.Backend
// pipeline of current running subtask, it's nil when no subtask is running.
currPipe atomic.Pointer[operator.AsyncPipeline]

m *lightningmetric.Common
Copy link
Contributor

Choose a reason for hiding this comment

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

doitto

Comment on lines 295 to 298
tk.MustExec("set @@global.tidb_cloud_storage_uri = '';")
tk.MustExec("alter table t add index idx(a);")
tk.MustExec("alter table t drop index idx;")

Copy link
Contributor

Choose a reason for hiding this comment

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

what's this test for? if you set tk.MustExec("set @@global.tidb_cloud_storage_uri = '';"). it might break later cases

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me remove it

Co-authored-by: D3Hunter <jujj603@gmail.com>
Copy link
Contributor

@joechenrh joechenrh left a comment

Choose a reason for hiding this comment

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

Rest LGTM

Copy link

ti-chi-bot bot commented May 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: joechenrh, 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 6, 2025
Copy link

ti-chi-bot bot commented May 6, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-30 08:09:39.372635589 +0000 UTC m=+1034323.184425970: ☑️ agreed by tangenta.
  • 2025-05-06 02:40:49.82637982 +0000 UTC m=+322897.009283076: ☑️ agreed by joechenrh.

Co-authored-by: Ruihao Chen <joechenrh@gmail.com>
@CbcWestwolf
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit e217a01 into pingcap:master May 6, 2025
27 checks passed
@CbcWestwolf CbcWestwolf deleted the ddl_metrics branch May 6, 2025 04:25
@CbcWestwolf
Copy link
Member Author

/cherrypick release-8.1
/cherrypick release-8.5

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 25, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@CbcWestwolf: new pull request created to branch release-8.1: #61980.
But this PR has conflicts, please resolve them!

In response to this:

/cherrypick release-8.1
/cherrypick release-8.5

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 ti-community-infra/tichi repository.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jun 25, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

@CbcWestwolf: new pull request created to branch release-8.5: #61981.
But this PR has conflicts, please resolve them!

In response to this:

/cherrypick release-8.1
/cherrypick release-8.5

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 ti-community-infra/tichi repository.

CbcWestwolf added a commit to ti-chi-bot/tidb that referenced this pull request Jun 25, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@CbcWestwolf CbcWestwolf mentioned this pull request Jul 3, 2025
13 tasks
ti-chi-bot bot pushed a commit that referenced this pull request Jul 4, 2025
ti-chi-bot bot pushed a commit that referenced this pull request Jul 4, 2025
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Jul 11, 2025
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Jul 11, 2025
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #62379.
But this PR has conflicts, please resolve them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backfilling for adding index needs a metric to display the speed of writing kvs
5 participants