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

Fixed deadlock problem caused by concurrent auto create schema and delete database #12489

Conversation

OneSizeFitsQuorum
Copy link
Contributor

No description provided.

Signed-off-by: OneSizeFitQuorum <tanxinyu@apache.org>
Copy link

sonarcloud bot commented May 8, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

codecov bot commented May 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.43%. Comparing base (3cca91d) to head (a8c80a4).

Additional details and impacted files
@@             Coverage Diff              @@
##             master   #12489      +/-   ##
============================================
- Coverage     43.45%   43.43%   -0.03%     
  Complexity       69       69              
============================================
  Files          3109     3109              
  Lines        192931   192931              
  Branches      22971    22971              
============================================
- Hits          83835    83791      -44     
- Misses       109096   109140      +44     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@CRZbulabula CRZbulabula 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
Contributor

@CRZbulabula CRZbulabula left a comment

Choose a reason for hiding this comment

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

After detail analysis, the process of producing deadlock is as follows:

  1. The PartitionFetcher requires a read lock for SchemaRegions when create database.
  2. The DeleteDatabaseProcedure requires a write lock for SchemaRegions when delete database.
  3. Both create and delete database process are serialized.

Therefore, the DeleteDatabaseProcedure would never obtain the write lock for SchemaRegions when the read lock is already took by PartitionFetcher.

Our solution is to decompose the serialization of create and delete database interfaces. Thus, the DeleteDatabaseProcedure could obtain the write lock after the creation process finish. We've checked the code to ensure that there are no severe parallel bugs after we cancel the serializition

@OneSizeFitsQuorum OneSizeFitsQuorum merged commit f929245 into master May 20, 2024
57 of 59 checks passed
@SteveYurongSu SteveYurongSu deleted the try_to_fix_dealock_cause_by_auto_create_schema_and_delete_database branch May 20, 2024 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants