Skip to content

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Apr 25, 2025

What problem does this PR solve?

Issue Number: close #60145

Problem Summary:

#56404 introduced the step context for each step of a DDL job. runReorgJob is changed to a blocking implementation, resulting in the inability to update job's row count.

What changed and how does it work?

This PR returns dbterror.ErrWaitReorgTimeout periodically to let the routine of runJobOneStep update job's row count. It also manages stepCtx carefully to avoid premature cancelling.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
    The previous behavior was to run one job step and then get stuck inside.
    Now the behavior is that it exits periodically, so there are many run one job steps, and the job row count is updated.
    [2025/04/25 11:14:56.185 +08:00] [INFO] [job_worker.go:816] ["run one job step"] [category=ddl] [jobID=129] [conn=1214251012] [job="ID:129, Type:add index, State:running, SchemaState:write reorganization, SchemaID:2, TableID:112, RowCount:541994, ArgLen:0,   start time: 2025-04-25 11:14:22.977 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:457585685463564289, Version: v2, UniqueWarnings:0"]
    [2025/04/25 11:14:58.377 +08:00] [INFO] [advancer.go:678] ["No tasks yet, skipping advancing."]
    [2025/04/25 11:15:01.212 +08:00] [INFO] [job_worker.go:816] ["run one job step"] [category=ddl] [jobID=129] [conn=1214251012] [job="ID:129, Type:add index, State:running, SchemaState:write reorganization, SchemaID:2, TableID:112, RowCount:631338, ArgLen:0,   start time: 2025-04-25 11:14:22.977 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:457585685463564289, Version: v2, UniqueWarnings:0"]
    [2025/04/25 11:15:05.369 +08:00] [INFO] [backfilling.go:386] ["backfill worker back fill index"] [category=ddl] [worker="backfill-worker 3, tp add index"] [addedCount=360448] [scanCount=360448] ["next key"=7480000000000000705f7280000000000df79600] [speed  (rows/s)=9001.939254991426]
    [2025/04/25 11:15:05.411 +08:00] [INFO] [backfilling.go:386] ["backfill worker back fill index"] [category=ddl] [worker="backfill-worker 1, tp add index"] [addedCount=360448] [scanCount=360448] ["next key"=7480000000000000705f72800000000005b9da00] [speed  (rows/s)=9009.241181952648]
    [2025/04/25 11:15:06.234 +08:00] [INFO] [job_worker.go:816] ["run one job step"] [category=ddl] [jobID=129] [conn=1214251012] [job="ID:129, Type:add index, State:running, SchemaState:write reorganization, SchemaID:2, TableID:112, RowCount:725290, ArgLen:0,   start time: 2025-04-25 11:14:22.977 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:457585685463564289, Version: v2, UniqueWarnings:0"]
    [2025/04/25 11:15:10.377 +08:00] [INFO] [advancer.go:678] ["No tasks yet, skipping advancing."]
    [2025/04/25 11:15:11.254 +08:00] [INFO] [job_worker.go:816] ["run one job step"] [category=ddl] [jobID=129] [conn=1214251012] [job="ID:129, Type:add index, State:running, SchemaState:write reorganization, SchemaID:2, TableID:112, RowCount:818730, ArgLen:0,   start time: 2025-04-25 11:14:22.977 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:457585685463564289, Version: v2, UniqueWarnings:0"]
    
  • 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.

None

@ti-chi-bot ti-chi-bot bot added 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. labels Apr 25, 2025
Copy link

tiprow bot commented Apr 25, 2025

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

Copy link

codecov bot commented Apr 25, 2025

Codecov Report

Attention: Patch coverage is 96.55172% with 2 lines in your changes missing coverage. Please review.

Project coverage is 75.1744%. Comparing base (c489679) to head (0ca1d39).
Report is 16 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #60828        +/-   ##
================================================
+ Coverage   73.1336%   75.1744%   +2.0408%     
================================================
  Files          1716       1765        +49     
  Lines        475706     490410     +14704     
================================================
+ Hits         347901     368663     +20762     
+ Misses       106437      98926      -7511     
- Partials      21368      22821      +1453     
Flag Coverage Δ
integration 49.0229% <74.1379%> (?)
unit 72.6342% <96.5517%> (+0.2650%) ⬆️

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

Components Coverage Δ
dumpling 52.7118% <ø> (+0.0564%) ⬆️
parser ∅ <ø> (∅)
br 62.3795% <ø> (+15.0197%) ⬆️
🚀 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.

@joccau joccau requested review from D3Hunter, lance6716 and mjonss and removed request for D3Hunter, lance6716 and mjonss April 25, 2025 09:38
@joccau
Copy link
Contributor

joccau commented Apr 25, 2025

/test unit-test

Copy link

tiprow bot commented Apr 25, 2025

@joccau: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run the following jobs that were automatically triggered:

  • tidb_parser_test

In response to this:

/test unit-test

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 added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Apr 25, 2025
@tangenta
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 25, 2025

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

Copy link
Contributor

@D3Hunter D3Hunter 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

jobCtx.stepCtx, cancelStep = context.WithCancelCause(jobCtx.ctx)
defer cancelStep(context.Canceled)
jobCtx.initStepCtx()
defer jobCtx.cleanStepCtx()
w.wg.Run(func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

every time we enter runOneJobStep, we will refresh the job, so if we change back to the old bahavior, there is no need to keep this routine

but if we do remove this routine, will cancel be blocked? as fixed in #56404 cc @lance6716

Copy link
Contributor

Choose a reason for hiding this comment

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

but if we do remove this routine, will cancel be blocked?

In this PR, I see in line 886 still calls stepCtxCancel, so cancel should still be seen and processed timely.

Signed-off-by: tangenta <[email protected]>
Signed-off-by: tangenta <[email protected]>
Signed-off-by: tangenta <[email protected]>
Signed-off-by: tangenta <[email protected]>
Copy link
Collaborator

@Benjamin2037 Benjamin2037 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 approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 27, 2025
Copy link

ti-chi-bot bot commented Apr 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, D3Hunter

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 Apr 27, 2025
Copy link

ti-chi-bot bot commented Apr 27, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-04-27 02:31:17.101448195 +0000 UTC m=+754820.913238576: ☑️ agreed by Benjamin2037.
  • 2025-04-27 08:30:27.603709208 +0000 UTC m=+776371.415499589: ☑️ agreed by D3Hunter.

@tangenta
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 27, 2025

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

@tangenta
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 27, 2025

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

@tangenta
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Apr 27, 2025

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

@ti-chi-bot ti-chi-bot bot merged commit e8fb24a into pingcap:master Apr 27, 2025
26 checks passed
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 27, 2025
Kiran01bm pushed a commit to Kiran01bm/tidb that referenced this pull request Apr 29, 2025
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-8.5 Should cherry pick this PR to release-8.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.

ddl: ROW_COUNT display abnormally in txn mode when adding index
6 participants