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

Shutdown sequence fixes #2652

Merged
merged 4 commits into from
Aug 22, 2022
Merged

Shutdown sequence fixes #2652

merged 4 commits into from
Aug 22, 2022

Conversation

roman-khimov
Copy link
Member

Some tests failed on me.

It never runs the server, so 746644a was a
bit wrong with this.
@roman-khimov roman-khimov added the bug Something isn't working label Aug 19, 2022
@roman-khimov roman-khimov added this to the v0.99.3 milestone Aug 19, 2022
Unsubscribe and drain first, then return from the Shutdown method. It's
important wrt to subsequent chain shutdown process (normally it's closed right
after the network server).
Blockchain's notificationDispatcher sends events to channels and these
channels must be read from. Unfortunately, regular service shutdown procedure
does unsubscription first (outside of the read loop) and only then drains the
channel. While it waits for unsubscription request to be accepted
notificationDispatcher can try pushing more data into the same channel which
will lead to a deadlock. Reading in the same method solves this, any number of
events can be pushed until unsub channel accepts the data.
And synchronize other threads with channels instead of mutexes. Overall this
scheme is more reliable.
@codecov
Copy link

codecov bot commented Aug 19, 2022

Codecov Report

Merging #2652 (779a5c0) into master (823c4b3) will decrease coverage by 0.08%.
The diff coverage is 92.15%.

@@            Coverage Diff             @@
##           master    #2652      +/-   ##
==========================================
- Coverage   85.13%   85.04%   -0.09%     
==========================================
  Files         315      315              
  Lines       38841    38866      +25     
==========================================
- Hits        33067    33054      -13     
- Misses       4418     4458      +40     
+ Partials     1356     1354       -2     
Impacted Files Coverage Δ
pkg/consensus/consensus.go 72.98% <ø> (ø)
pkg/services/notary/notary.go 82.63% <ø> (ø)
pkg/services/rpcsrv/server.go 76.77% <ø> (ø)
pkg/services/stateroot/service.go 76.54% <ø> (ø)
pkg/core/blockchain.go 81.84% <90.90%> (-0.03%) ⬇️
pkg/network/discovery.go 98.75% <100.00%> (+0.01%) ⬆️
pkg/network/server.go 73.25% <100.00%> (+0.07%) ⬆️
pkg/network/payload/mptdata.go 81.25% <0.00%> (-18.75%) ⬇️
pkg/services/oracle/oracle.go 72.79% <0.00%> (-14.71%) ⬇️
pkg/services/oracle/request.go 57.99% <0.00%> (-5.03%) ⬇️
... and 3 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@roman-khimov roman-khimov merged commit 606597b into master Aug 22, 2022
@roman-khimov roman-khimov deleted the shutdown-fixes branch August 22, 2022 07:22
@roman-khimov roman-khimov removed U3 Regular 2022Q3 labels Sep 12, 2022
@roman-khimov roman-khimov removed U3 Regular 2022Q3 labels Sep 13, 2022
@roman-khimov roman-khimov removed U3 Regular 2022Q3 labels Sep 13, 2022
@roman-khimov roman-khimov removed U3 Regular 2022Q3 labels Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants