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: handle cluster state retrieval failure #53816

Merged
merged 4 commits into from
Jun 6, 2024

Conversation

tangenta
Copy link
Contributor

@tangenta tangenta commented Jun 5, 2024

What problem does this PR solve?

Issue Number: close #53808

Problem Summary:

When TiDB is just elected as the DDL owner and startDispatchLoop is not started, there maybe a "context canceled" error when owner retired for some reasons(like PD connection issue):

[2024/06/03 12:42:37.820 +08:00] [INFO] [manager.go:232] ["retire owner"] ["owner info"="[ddl] /tidb/ddl/fg/owner ownerManager 4e189321-5fd4-48fa-ad33-a8a92ed10cef"]
[2024/06/03 12:42:37.820 +08:00] [INFO] [syncer.go:485] ["schema version sync loop interrupted, retrying..."] [category=ddl]
[2024/06/03 12:42:37.820 +08:00] [WARN] [job_table.go:424] ["get global state failed"] [category=ddl] [error="context canceled"]
[2024/06/03 12:42:37.820 +08:00] [FATAL] [job_table.go:366] ["dispatch loop get cluster state failed, it should not happen, please try restart TiDB"] [category=ddl] [error="context canceled"] [stack="github.com/pingcap/tidb/pkg/ddl.(*jobScheduler).startDispatchLoop\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/ddl/job_table.go:366\ngit.luolix.top/pingcap/tidb/pkg/util.(*WaitGroupWrapper).RunWithLog.func1\n\t/home/jenkins/agent/workspace/build-common/go/src/github.com/pingcap/tidb/pkg/util/wait_group_wrapper.go:171"]

What changed and how does it work?

Since startDispatchLoop is not only called at TiDB cluster initialization, we should not os.Exit(1).

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 do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 5, 2024
Copy link

tiprow bot commented Jun 5, 2024

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 Jun 5, 2024

Codecov Report

Attention: Patch coverage is 52.38095% with 10 lines in your changes missing coverage. Please review.

Project coverage is 55.9252%. Comparing base (8483dc5) to head (cc89fb8).
Report is 32 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #53816         +/-   ##
=================================================
- Coverage   72.5705%   55.9252%   -16.6454%     
=================================================
  Files          1506       1627        +121     
  Lines        431000     609124     +178124     
=================================================
+ Hits         312779     340654      +27875     
- Misses        98912     245245     +146333     
- Partials      19309      23225       +3916     
Flag Coverage Δ
integration 36.7612% <52.3809%> (?)
unit 71.4414% <52.3809%> (-0.1249%) ⬇️

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

Components Coverage Δ
dumpling 52.9656% <ø> (-1.0302%) ⬇️
parser ∅ <ø> (∅)
br 50.2833% <ø> (+8.4702%) ⬆️

pkg/ddl/job_table.go Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 5, 2024
@tangenta
Copy link
Contributor Author

tangenta commented Jun 5, 2024

/retest

Copy link

tiprow bot commented Jun 5, 2024

@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 added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 5, 2024
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 5, 2024
Copy link

ti-chi-bot bot commented Jun 5, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-06-05 02:30:57.961984196 +0000 UTC m=+3434811.719119766: ☑️ agreed by D3Hunter.
  • 2024-06-05 06:20:10.35694861 +0000 UTC m=+3448564.114084183: ☑️ agreed by lance6716.

@lance6716
Copy link
Contributor

@tangenta you can approve yourself

@tangenta
Copy link
Contributor Author

tangenta commented Jun 5, 2024

@tangenta you can approve yourself

Author cannot approve his own PR..

@tangenta
Copy link
Contributor Author

tangenta commented Jun 5, 2024

/approve

@ti-chi-bot ti-chi-bot bot added the approved label Jun 5, 2024
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jun 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@D3Hunter
Copy link
Contributor

D3Hunter commented Jun 5, 2024

we should keep retry as long as we're still the owner, like what SyncJobSchemaVerLoop does

@tangenta
Copy link
Contributor Author

tangenta commented Jun 5, 2024

/hold

@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 Jun 5, 2024
@tangenta
Copy link
Contributor Author

tangenta commented Jun 5, 2024

we should keep retry as long as we're still the owner, like what SyncJobSchemaVerLoop does

@D3Hunter 3fd88a1

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

pkg/ddl/job_table.go Outdated Show resolved Hide resolved
pkg/ddl/job_table.go Outdated Show resolved Hide resolved
pkg/ddl/job_table.go Outdated Show resolved Hide resolved
pkg/ddl/job_table.go Outdated Show resolved Hide resolved
@tangenta
Copy link
Contributor Author

tangenta commented Jun 6, 2024

/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 Jun 6, 2024
@ti-chi-bot ti-chi-bot bot merged commit b8c0865 into pingcap:master Jun 6, 2024
21 checks passed
@D3Hunter D3Hunter mentioned this pull request Jun 19, 2024
18 tasks
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
4 participants