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

Fix Concurrency Bug In CommitToParent #1320

Merged
merged 16 commits into from
Apr 11, 2023
Merged

Fix Concurrency Bug In CommitToParent #1320

merged 16 commits into from
Apr 11, 2023

Conversation

dboehm-avalabs
Copy link
Contributor

CommitToParent can happen concurrently so it may cause the parent of a view to change during its own attempt to commit to its parent(see the new unit tests). This isn't an issue for CommitToDB as it uses the commit lock.

@dboehm-avalabs dboehm-avalabs changed the base branch from master to dev April 11, 2023 14:44
@@ -222,10 +222,8 @@ func (t *trieView) calculateNodeIDs(ctx context.Context) error {

// ensure that the view under this one is up-to-date before potentially pulling in nodes from it
// getting the Merkle root forces any unupdated nodes to recalculate their ids
if t.parentTrie != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

detects as race and no longer needed. Hold over from when views could have no parent view.

x/merkledb/db.go Outdated Show resolved Hide resolved
x/merkledb/db.go Outdated Show resolved Hide resolved
t.db.commitLock.Lock()
defer t.db.commitLock.Unlock()
}
t.db.commitLock.Lock()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Prevents multiple commits from occurring at the same time until I can figure out a way to manage the safety of this.

@danlaine danlaine merged commit 9cf116b into dev Apr 11, 2023
@danlaine danlaine deleted the FixCommitToParentBug branch April 11, 2023 19:33
abi87 pushed a commit that referenced this pull request Apr 13, 2023
Co-authored-by: Dan Laine <daniel.laine@avalabs.org>
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.

3 participants