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

disagg: Fix a potential crash when shutting down (#8848) #8914

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #8848

What problem does this PR solve?

Issue Number: close #8837

Problem Summary:

There is a logging about "std::exception. Code: 1001, type: std::__1::system_error, e.what() = thread::join failed: Resource deadlock avoided". Usually it is caused by a thread is trying to call join for the thread itself.

There is a chance that the task handle (shared_ptr) is being held by the background pool thread

TaskHandle task = tryPopTask(rng);
if (shutdown)
break;

And the task handle could hold a shared_ptr to UniversalPageStorageService. So there could be a chance that:

  1. The main thread receive kill signal, UniversalPageStorageService::shutdown is called
  2. But there is a background pool thread holding a shared_ptr of remote_checkpoint_handle, which contains a shared_ptr of UniversalPageStorageService
  3. The shared_ptr of UniversalPageStorageService in the ContextShared is released
  4. The background pool thread try to release to shared_ptr of remote_checkpoint_handle, which cause the shared_ptr of UniversalPageStorageService being released. But the thread is created by UniversalPageStorageService::checkpoint_pool. So the thread run into calling join on itself and causing the system_error

What is changed and how it works?

Use a weak_ptr of UniversalPageStorageService instead of shared_ptr. So that even when the remote_checkpoint_handle is still holding by the background pool thread, it won't cause the background pool thread calling join on itself. Because the share counter of UniversalPageStorageService must go down to 0 outside of the background pool thread.

Check List

Tests

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

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

Fix a potential crash when shutting down under disagg arch

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR. labels Apr 9, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Apr 9, 2024
@JaySon-Huang
Copy link
Contributor

/run-all-tests

@JaySon-Huang JaySon-Huang requested review from JinheLin and CalvinNeo May 7, 2024 09:02
Copy link
Contributor

@JaySon-Huang JaySon-Huang 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 needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels May 7, 2024
@JaySon-Huang
Copy link
Contributor

/run-all-tests

@JaySon-Huang
Copy link
Contributor

/run-all-tests

Copy link
Contributor

ti-chi-bot bot commented May 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, JinheLin

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:
  • OWNERS [JaySon-Huang,JinheLin]

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

ti-chi-bot bot commented May 8, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-05-07 09:03:01.214389767 +0000 UTC m=+952734.971525339: ☑️ agreed by JaySon-Huang.
  • 2024-05-08 03:30:13.233335839 +0000 UTC m=+1019166.990471411: ☑️ agreed by JinheLin.

Copy link
Contributor

ti-chi-bot bot commented May 8, 2024

@ti-chi-bot: Your PR was out of date, I have automatically updated it for you.

At the same time I will also trigger all tests for you:

/run-all-tests

trigger some heavy tests which will not run always when PR updated.

If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

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 ti-chi-bot bot merged commit 3691fdf into pingcap:release-7.5 May 8, 2024
5 checks passed
JaySon-Huang pushed a commit to JaySon-Huang/tiflash that referenced this pull request Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-7.5 This PR is cherry-picked to release-7.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants