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

ddl: refine some context usage #56243

Merged
merged 12 commits into from
Sep 27, 2024
Merged

Conversation

lance6716
Copy link
Contributor

@lance6716 lance6716 commented Sep 24, 2024

What problem does this PR solve?

Issue Number: ref #56017 ref #54436

Problem Summary:

What changed and how does it work?

changed some functions to use correct context.

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.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/needs-triage-completed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 24, 2024
Copy link

tiprow bot commented Sep 24, 2024

Hi @lance6716. 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 Sep 24, 2024

Codecov Report

Attention: Patch coverage is 87.32394% with 9 lines in your changes missing coverage. Please review.

Project coverage is 76.3608%. Comparing base (01797cb) to head (a8d6af7).
Report is 24 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #56243        +/-   ##
================================================
+ Coverage   73.4215%   76.3608%   +2.9392%     
================================================
  Files          1619       1648        +29     
  Lines        446764     462300     +15536     
================================================
+ Hits         328021     353016     +24995     
+ Misses        98638      87718     -10920     
- Partials      20105      21566      +1461     
Flag Coverage Δ
integration 52.0226% <61.9718%> (?)
unit 72.6038% <77.4647%> (+0.0978%) ⬆️

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

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 63.0792% <100.0000%> (+17.5564%) ⬆️

Signed-off-by: lance6716 <[email protected]>
@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 Sep 24, 2024
Signed-off-by: lance6716 <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 24, 2024
@lance6716 lance6716 changed the title [WIP]ddl: poll job cancel status and cancel ctx ddl: poll job cancel status and cancel ctx Sep 24, 2024
@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 Sep 24, 2024
@lance6716 lance6716 changed the title ddl: poll job cancel status and cancel ctx ddl: poll job state and cancel ctx Sep 24, 2024
@lance6716 lance6716 changed the title ddl: poll job state and cancel ctx ddl: poll job state and cancel ctx for ingest in background Sep 24, 2024
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 26, 2024
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.

20/27

@@ -2738,7 +2738,7 @@ func (w *worker) onExchangeTablePartition(jobCtx *jobContext, t *meta.Meta, job
zap.Stringer("job", job), zap.Int64("defID", defID), zap.Int64("partDef.ID", partDef.ID))
job.Args[0] = partDef.ID
defID = partDef.ID
err = updateDDLJob2Table(w.sess, job, true)
err = updateDDLJob2Table(w.ctx, w.sess, job, true)
Copy link
Contributor

Choose a reason for hiding this comment

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

use context from jobCtx

below too

return &OperatorCtx{
Context: opCtx,
cancel: cancel,
}
}, cancel
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just use OperatorCtx.Cancel?

Copy link
Contributor Author

@lance6716 lance6716 Sep 26, 2024

Choose a reason for hiding this comment

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

the unused variable (cancel) can remind the caller. This PR fixes some functions that forget to cancel, like line 678 in pkg/ddl/backfilling.go in the old code.

Copy link
Contributor

Choose a reason for hiding this comment

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

I doubt the remind part, coders can simple ignore it as OperatorCtx already has it

We should unify the place to call cancel, not scattering it all around

Copy link
Contributor Author

@lance6716 lance6716 Sep 26, 2024

Choose a reason for hiding this comment

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

The developers have forgotten to call OperatorCtx.Cancel at line 678 in pkg/ddl/backfilling.go (there's also a missing in unit test files), so I prefer to use golang's built-in detect of unused variables to prevent future bug.

Copy link
Contributor

Choose a reason for hiding this comment

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

static checks doesn't help those logic bugs, but ok anyway

Signed-off-by: lance6716 <[email protected]>
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


// spawn a goroutine to check if the job is cancelled
// TODO: design a more systematic way to cancel DDL jobs
var wg sync.WaitGroup
Copy link
Contributor

Choose a reason for hiding this comment

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

use our WaitGroup wrapper

}
defer sessPool.Put(sctx)

ticker := time.NewTicker(time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe reduce reorgWaitTime, we will check it in worker's runJobStep loop anyway

tidb/pkg/ddl/reorg.go

Lines 403 to 404 in 9dff38b

waitTimeout := ReorgWaitTimeout
// wait reorganization job done or timeout

@lance6716

This comment was marked as outdated.

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2024
@lance6716 lance6716 changed the title ddl: poll job state and cancel ctx for ingest in background [WIP]ddl: poll job state and cancel ctx in background Sep 27, 2024
@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 Sep 27, 2024
Signed-off-by: lance6716 <[email protected]>
Signed-off-by: lance6716 <[email protected]>
@lance6716 lance6716 changed the title [WIP]ddl: poll job state and cancel ctx in background ddl: refine some context usage Sep 27, 2024
@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 Sep 27, 2024
@lance6716
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 27, 2024
Copy link

ti-chi-bot bot commented Sep 27, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-09-26 07:36:10.06156099 +0000 UTC m=+1724239.801984926: ☑️ agreed by tangenta.
  • 2024-09-27 08:12:19.534516229 +0000 UTC m=+1812809.274940167: ☑️ agreed by D3Hunter.

@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Sep 27, 2024

@lance6716: 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.

@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Sep 27, 2024

@lance6716: 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

ti-chi-bot bot commented Sep 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, tangenta, YuJuncen

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

ti-chi-bot bot commented Sep 27, 2024

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

Test name Commit Details Required Rerun command
pull-br-integration-test a8d6af7 link unknown /test pull-br-integration-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/test-infra repository. I understand the commands that are listed here.

@lance6716
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Sep 27, 2024

@lance6716: 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 bad2ecd into pingcap:master Sep 27, 2024
32 of 33 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-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants