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

Problem: memiavl rootmulti integration is not thread-safe to use #1002

Merged
merged 3 commits into from
Apr 25, 2023

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Apr 25, 2023

Closes: #977

Solution:

  • add mutex to memiavl.DB.

The assumptions to concurrency:

  • The methods on DB are protected by a mutex
  • each call of LoadVersion loads a separate instance, in query scenarios, it should be immutable, the cache stores will handle the temporary writes.
  • the DB for the state machine will handle writes through the Commit call, this method is the sole entry point for tree modifications, and there's no concurrency internally (the background snapshot rewrite is handled separately), so we don't need locks in the Tree.

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

@yihuang yihuang requested a review from a team as a code owner April 25, 2023 02:14
@yihuang yihuang requested review from mmsqe and devashishdxt and removed request for a team April 25, 2023 02:14
@codecov
Copy link

codecov bot commented Apr 25, 2023

Codecov Report

Merging #1002 (276a6bf) into main (ca10265) will increase coverage by 0.22%.
The diff coverage is 70.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1002      +/-   ##
==========================================
+ Coverage   44.80%   45.02%   +0.22%     
==========================================
  Files          80       80              
  Lines        6606     6669      +63     
==========================================
+ Hits         2960     3003      +43     
- Misses       3322     3342      +20     
  Partials      324      324              
Impacted Files Coverage Δ
memiavl/db.go 58.46% <70.14%> (+3.13%) ⬆️

memiavl/db.go Show resolved Hide resolved
memiavl/db.go Outdated Show resolved Hide resolved
Co-authored-by: mmsqe <tqd0800210105@gmail.com>
Signed-off-by: yihuang <huang@crypto.com>
@yihuang yihuang enabled auto-merge April 25, 2023 03:46
@yihuang yihuang added this pull request to the merge queue Apr 25, 2023
Merged via the queue into crypto-org-chain:main with commit 73af001 Apr 25, 2023
@yihuang yihuang deleted the mutex branch April 25, 2023 06:02
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.

Problem: memiavl rootmulti integration is not thread-safe to use
2 participants