Skip to content

remove Deadlock from lib/grandpa/message_tracker.go #2923

Merged
kishansagathiya merged 12 commits intodevelopmentfrom
kishan/fix/grandpa-deadlock
Nov 15, 2022
Merged

remove Deadlock from lib/grandpa/message_tracker.go #2923
kishansagathiya merged 12 commits intodevelopmentfrom
kishan/fix/grandpa-deadlock

Conversation

@kishansagathiya
Copy link
Copy Markdown
Contributor

remove common mapLock from map tracker and have two separate locks for commit tracker and vote tracker

Changes

Tests

go test -tags integration github.com/ChainSafe/gossamer

Issues

Fixes #2841

Primary Reviewer

@EclesioMeloJunior

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 4, 2022

Codecov Report

Merging #2923 (a26ccf5) into development (ac2af46) will increase coverage by 0.07%.
The diff coverage is 100.00%.

Additional details and impacted files
@@               Coverage Diff               @@
##           development    #2923      +/-   ##
===============================================
+ Coverage        63.29%   63.36%   +0.07%     
===============================================
  Files              218      218              
  Lines            27533    27542       +9     
===============================================
+ Hits             17426    17453      +27     
+ Misses            8495     8480      -15     
+ Partials          1612     1609       -3     

Copy link
Copy Markdown
Contributor

@qdm12 qdm12 left a comment

Choose a reason for hiding this comment

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

When do you get such deadlock? A bit more context would be nice 😉

EDIT: never mind I'm an idiot, I just read the issue linked 👍

Comment thread lib/grandpa/commits_tracker.go
Comment thread lib/grandpa/commits_tracker.go
Comment thread lib/grandpa/commits_tracker_test.go
Comment thread lib/grandpa/votes_tracker_test.go
Comment thread lib/grandpa/votes_tracker.go
Comment thread lib/grandpa/votes_tracker.go
Comment thread lib/grandpa/votes_tracker.go
Comment thread lib/grandpa/message_tracker_test.go Outdated
Comment thread lib/grandpa/commits_tracker.go
Comment thread lib/grandpa/votes_tracker_test.go
Copy link
Copy Markdown
Member

@EclesioMeloJunior EclesioMeloJunior left a comment

Choose a reason for hiding this comment

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

There are no tests related to the commits in the tracker so I would like to suggest adding tests to it

Comment thread lib/grandpa/commits_tracker.go
@qdm12
Copy link
Copy Markdown
Contributor

qdm12 commented Nov 9, 2022

There are no tests related to the commits in the tracker so I would like to suggest adding tests to it

What do you mean? There is lib/grandpa/commits_tracker_test.go right?

There are no tests for the callers of the commits tracker, although I have a local WIP branch with these (waiting for a grandpa refactor and/or something like #2575)

@EclesioMeloJunior
Copy link
Copy Markdown
Member

What do you mean? There is lib/grandpa/commits_tracker_test.go right?

There are no tests for the callers of the commits tracker, although I have a local WIP branch with these (waiting for a grandpa refactor and/or something like #2575)

The message tracker handles vote messages and commit messages, but in the message_tracker_test.go there is no tests related to adding a commit to the tracker and calling the (t *tracker) handleTick method, the test TestMessageTracker_handleTick only tests vote messages, so I would suggest to add one more case to tests the commit messages as well

@qdm12
Copy link
Copy Markdown
Contributor

qdm12 commented Nov 11, 2022

The message tracker handles vote messages and commit messages, but in the message_tracker_test.go there is no tests related to adding a commit to the tracker and calling the (t *tracker) handleTick method, the test TestMessageTracker_handleTick only tests vote messages, so I would suggest to add one more case to tests the commit messages as well

Yeah.... That's what I was trying to do a few months ago, but it's kinda of a pain in the ass to write good enough unit tests due to the impl details of the subtrackers (and the unexported fields of the linked lists)... so we would need interfaces... ideally internal subpackages for the 2 trackers and dep inject them to the parent tracker... but then we need #2575 ... anyway probably overthinking it lol...

We can for sure make an integration test without too much testing depth.

Copy link
Copy Markdown
Member

@EclesioMeloJunior EclesioMeloJunior left a comment

Choose a reason for hiding this comment

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

LGTM!

@kishansagathiya kishansagathiya merged commit bb637ff into development Nov 15, 2022
@kishansagathiya kishansagathiya deleted the kishan/fix/grandpa-deadlock branch November 15, 2022 06:54
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 0.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

Deadlock at lib/grandpa/message_tracker.go

4 participants