Skip to content

*: add log for bootstrap part and init USR1 single handler early to help diagnose#61997

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
D3Hunter:log-signal-for-diag
Jun 26, 2025
Merged

*: add log for bootstrap part and init USR1 single handler early to help diagnose#61997
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
D3Hunter:log-signal-for-diag

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Jun 25, 2025

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:

What changed and how does it work?

when the only instance set tidb-enable-ddl = false, it will block on bootstrap, or the keyspace doesn't created on PD, it will block on creating store, but we don't know where, as there is no log, and we cannot get stack as the signal handler hasn't been setup and the server hasn't started yet, so we add this pr to help diagnose.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

run a single tidb-server for some keyspace, and set tidb-enable-ddl = false, we can see from log

[2025/06/25 15:26:14.620 +08:00] [INFO] [bootstrap.go:846] ["bootstrap not done yet, waiting for owner to finish"] [keyspaceName=ks1] [sampled=]
[2025/06/25 15:26:44.641 +08:00] [INFO] [bootstrap.go:846] ["bootstrap not done yet, waiting for owner to finish"] [keyspaceName=ks1] [sampled=]

run tidb-server with a un-registered keyspace, tidb will retry on get keyspace meta

from log we can see it meet ErrKeyspaceNotFound error, and retry

[store.go:96] ["open store failed, retrying"] [keyspaceName=aks1] [path="tikv://localhost:2379?keyspaceName=aks1"] [sampled=]
   [error="Load keyspace aks1 failed: type:ENTRY_NOT_FOUND message:\"[PD:keyspace:ErrKeyspaceNotFound]keyspace does not exist\" "] 

kill -USR1, we can see the stack

=== Got signal [user defined signal 1] to dump goroutine stack. ===
goroutine 38 [running]:
github.com/pingcap/tidb/pkg/util/signal.getGoroutineStacks()
        /Users/jujiajia/code/pingcap/tidb/pkg/util/signal/signal_posix.go:42 +0x60
github.com/pingcap/tidb/pkg/util/signal.SetupUSR1Handler.func1()
        /Users/jujiajia/code/pingcap/tidb/pkg/util/signal/signal_posix.go:67 +0x90
created by github.com/pingcap/tidb/pkg/util/signal.SetupUSR1Handler in goroutine 1
        /Users/jujiajia/code/pingcap/tidb/pkg/util/signal/signal_posix.go:62 +0xf8

goroutine 1 [select]:
github.com/tikv/pd/client/servicediscovery.(*serviceDiscovery).initRetry(0x14001418b00, 0x1400141fe00)
        /Users/jujiajia/go/pkg/mod/github.com/tikv/pd/client@v0.0.0-20250623084542-60788950a745/servicediscovery/service_discovery.go:523 +0x188
github.com/tikv/pd/client/servicediscovery.(*serviceDiscovery).Init(0x14001418b00)
        /Users/jujiajia/go/pkg/mod/github.com/tikv/pd/client@v0.0.0-20250623084542-60788950a745/servicediscovery/service_discovery.go:496 +0x2e0
github.com/tikv/pd/client.(*innerClient).setup(0x1400100e000)
        /Users/jujiajia/go/pkg/mod/github.com/tikv/pd/client@v0.0.0-20250623084542-60788950a745/inner_client.go:261 +0x7c
github.com/tikv/pd/client.(*innerClient).init(0x1400100e000, 0x1400141fe00)
        /Users/jujiajia/go/pkg/mod/github.com/tikv/pd/client@v0.0.0-20250623084542-60788950a745/inner_client.go:66 +0x180
github.com/tikv/pd/client.newClientWithKeyspaceName({0x108b3b380, 0x10c57daa8}, {0x1073c1ed7, 0x10}, {0x14001352f83, 0x4}, {0x1400187db80, 0x1, 0x1}, {{0x0, ...}, ...}, ...)
        /Users/jujiajia/go/pkg/mod/github.com/tikv/pd/client@v0.0.0-20250623084542-60788950a745/client.go:393 +0x5d4
github.com/tikv/pd/client.NewClientWithAPIContext({0x108b3b380, 0x10c57daa8}, {0x108b17848, 0x1400187db90}, {0x1073c1ed7, 0x10}, {0x1400187db80, 0x1, 0x1}, {{0x0, ...}, ...}, ...)
        /Users/jujiajia/go/pkg/mod/github.com/tikv/pd/client@v0.0.0-20250623084542-60788950a745/client.go:335 +0x1dc
github.com/pingcap/tidb/pkg/store/driver.(*TiKVDriver).OpenWithOptions(0x140008cf200, {0x14001352f60, 0x27}, {0x0, 0x0, 0x0})
        /Users/jujiajia/code/pingcap/tidb/pkg/store/driver/tikv_driver.go:159 +0x6c0
github.com/pingcap/tidb/pkg/store/driver.(*TiKVDriver).Open(0x140008cf200, {0x14001352f60, 0x27})
        /Users/jujiajia/code/pingcap/tidb/pkg/store/driver/tikv_driver.go:108 +0x54
github.com/pingcap/tidb/pkg/store.newStoreWithRetry.func1()
        /Users/jujiajia/code/pingcap/tidb/pkg/store/store.go:94 +0x17c
github.com/pingcap/tidb/pkg/util.RunWithRetry(0x1e, 0x1f4, 0x14001c216b8)
        /Users/jujiajia/code/pingcap/tidb/pkg/util/misc.go:72 +0x60
github.com/pingcap/tidb/pkg/store.newStoreWithRetry({0x14001352f60, 0x27}, 0x1e)
        /Users/jujiajia/code/pingcap/tidb/pkg/store/store.go:92 +0x3c0
github.com/pingcap/tidb/pkg/store.New({0x14001352f60, 0x27})
        /Users/jujiajia/code/pingcap/tidb/pkg/store/store.go:75 +0x44
github.com/pingcap/tidb/pkg/store.mustInitStorage({0x14000188d91, 0x4})
        /Users/jujiajia/code/pingcap/tidb/pkg/store/store.go:172 +0x2c8
github.com/pingcap/tidb/pkg/store.MustInitStorage({0x14000188d91, 0x4})
        /Users/jujiajia/code/pingcap/tidb/pkg/store/store.go:147 +0x30
main.createStoreDDLOwnerMgrAndDomain({0x14000188d91, 0x4})
        /Users/jujiajia/code/pingcap/tidb/cmd/tidb-server/main.go:421 +0x3c
main.main()
        /Users/jujiajia/code/pingcap/tidb/cmd/tidb-server/main.go:339 +0x914
  • 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 25, 2025
@tiprow

tiprow Bot commented Jun 25, 2025

Copy link
Copy Markdown

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

Details

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.

@D3Hunter D3Hunter requested a review from lance6716 June 25, 2025 07:53
@codecov

codecov Bot commented Jun 25, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 41.37931% with 17 lines in your changes missing coverage. Please review.

Project coverage is 75.3512%. Comparing base (0870187) to head (c9eab9e).
Report is 6 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #61997        +/-   ##
================================================
+ Coverage   72.9521%   75.3512%   +2.3990%     
================================================
  Files          1735       1781        +46     
  Lines        482252     495302     +13050     
================================================
+ Hits         351813     373216     +21403     
+ Misses       108866      99112      -9754     
- Partials      21573      22974      +1401     
Flag Coverage Δ
integration 49.5502% <27.5862%> (?)
unit 72.6983% <100.0000%> (+0.4841%) ⬆️

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

Components Coverage Δ
dumpling 52.7804% <ø> (ø)
parser ∅ <ø> (∅)
br 63.0384% <ø> (+16.3765%) ⬆️
🚀 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.

@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Jun 25, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

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 the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 25, 2025
@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Jun 25, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

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 lance6716 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/hold

free to unhold after address comment

// all the goroutines. Start with 1 MB and try a few times, doubling each time.
// Give up and use a truncated trace if 64 MB is not enough.
buf := make([]byte, 1<<20)
for i := 0; ; i++ {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems i is not used?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

copied from golang source code, will keep it as long as ci pass

@ti-chi-bot ti-chi-bot Bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 25, 2025
@ti-chi-bot

ti-chi-bot Bot commented Jun 25, 2025

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2025-06-25 08:27:26.118270015 +0000 UTC m=+865098.841448997: ☑️ agreed by tiancaiamao.
  • 2025-06-25 08:39:33.401282932 +0000 UTC m=+865826.124461913: ☑️ agreed by lance6716.

@D3Hunter

Copy link
Copy Markdown
Contributor Author

/approve

@lance6716

Copy link
Copy Markdown
Contributor

/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 25, 2025
@ti-chi-bot

ti-chi-bot Bot commented Jun 26, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, lance6716, tiancaiamao, yudongusa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 Jun 26, 2025
@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Jun 26, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

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.

@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Jun 26, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

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.

@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Jun 26, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

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 679facd into pingcap:master Jun 26, 2025
27 checks passed
@D3Hunter D3Hunter deleted the log-signal-for-diag branch June 26, 2025 06:14
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

Development

Successfully merging this pull request may close these issues.

4 participants