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

Trie mutex refactoring #4984

Merged
merged 8 commits into from Feb 22, 2023
Merged

Trie mutex refactoring #4984

merged 8 commits into from Feb 22, 2023

Conversation

iulianpascalau
Copy link
Contributor

Reasoning behind the pull request

  • trie mutex refactoring

Proposed changes

  • trie mutex refactoring

Testing procedure

  • standard system tests: should not trigger WARN logs messages whenever the node is closing.

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

@iulianpascalau iulianpascalau changed the title - trie mutex refactoring Trie mutex refactoring Feb 14, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2023

Codecov Report

❗ No coverage uploaded for pull request base (rc/v1.5.0@58c008d). Click here to learn what that means.
Patch has no changes to coverable lines.

❗ Current head 00e073e differs from pull request most recent head 64d8b26. Consider uploading reports for the commit 64d8b26 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@             Coverage Diff              @@
##             rc/v1.5.0    #4984   +/-   ##
============================================
  Coverage             ?   70.64%           
============================================
  Files                ?      666           
  Lines                ?    86482           
  Branches             ?        0           
============================================
  Hits                 ?    61098           
  Misses               ?    20800           
  Partials             ?     4584           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

ssd04
ssd04 previously approved these changes Feb 14, 2023
Comment on lines 1102 to 1104
_, _, _ = tr.GetSerializedNodes([]byte("dog"), 1024)
wgEnd.Done()
fmt.Println("finished")
Copy link
Contributor

Choose a reason for hiding this comment

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

so we don't want to check the error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

forgotten prints :(
No, not quite, the storer is a stub anyway. GetSerializedNodes will error as it won't find some hashes, GetSerializedNode would have returned what the mock storer returned

ssd04
ssd04 previously approved these changes Feb 14, 2023
@@ -301,6 +295,9 @@ func (tr *patriciaMerkleTrie) recreate(root []byte, tsm common.StorageManager) (

// String outputs a graphical view of the trie. Mainly used in tests/debugging
func (tr *patriciaMerkleTrie) String() string {
tr.mutOperation.Lock()
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need here Lock?
you can use RLock

same for Get(), GetObsoleteHashes(), VerifyProof(), GetNumNodes(), GetOldRoot()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, we need the Lock/Unlock pair here and on all methods that are doing only get operations.
Reason: if the trie is collapsed/partially collapsed (as what happens after each Commit call) the nodes will hold only the collapsed version of the nodes on the last stored level. Then, at each traversing, the trie might try to fetch a collapsed node that will trigger the DB loading and altering of its containing pointers. So, because of the usage of the resolveCollapsed function, we can not use RLock/RUnlock functions. The concurrency test might not fail because is not big enough, but otherwise, it will fail on concurrent operations. Changed the test to have only one level in memory so it will fail if we change the Lock/Unlock to RLock/RUnlock.

Copy link
Collaborator

@gabi-vuls gabi-vuls left a comment

Choose a reason for hiding this comment

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

@@ Log scanner @@

trie-mutex-refactoring

================================================================================

  • Known Warnings 9
  • New Warnings 0
  • Known Errors 0
  • New Errors 0
  • Panics 0
    ================================================================================
  • block hash does not match 10283
  • miniblocks does not match 0
  • miniblock hash does not match 0
  • receipts hash missmatch 2
  • wrong nonce in block 3761
    ================================================================================
  • No jailed nodes on the thestnet
    ================================================================================

@iulianpascalau iulianpascalau merged commit fe91a59 into rc/v1.6.0 Feb 22, 2023
@iulianpascalau iulianpascalau deleted the trie-mutex-refactoring branch February 22, 2023 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants