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

node: Respond always to OS interrupts #2479

Merged
merged 2 commits into from
Sep 25, 2018
Merged

node: Respond always to OS interrupts #2479

merged 2 commits into from
Sep 25, 2018

Conversation

melekes
Copy link
Contributor

@melekes melekes commented Sep 24, 2018

Refs #2434

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG_PENDING.md

even during genesis sleep by setting up interrupt before starting a node

Refs #2434
to avoid

```
E[09-24|10:13:15.805] Not stopping PubSub -- have not been started yet module=pubsub impl=PubSub
```

being printed on exit
@codecov-io
Copy link

Codecov Report

Merging #2479 into develop will decrease coverage by 0.01%.
The diff coverage is 16.66%.

@@             Coverage Diff             @@
##           develop    #2479      +/-   ##
===========================================
- Coverage     61.7%   61.68%   -0.02%     
===========================================
  Files          198      198              
  Lines        16358    16364       +6     
===========================================
+ Hits         10093    10094       +1     
- Misses        5438     5443       +5     
  Partials       827      827
Impacted Files Coverage Δ
node/node.go 65.65% <ø> (+0.6%) ⬆️
cmd/tendermint/commands/run_node.go 0% <0%> (ø) ⬆️
p2p/transport.go 80% <66.66%> (-0.29%) ⬇️

@@ -207,7 +207,11 @@ func (mt *MultiplexTransport) Dial(
func (mt *MultiplexTransport) Close() error {
close(mt.closec)

return mt.listener.Close()
if mt.listener != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this to not panic when Close is called before Listen? When does that happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. There's a problem with the current common#Service implementation where it considers a service started before OnStart() finishes.

if atomic.CompareAndSwapUint32(&bs.started, 0, 1) {
if atomic.LoadUint32(&bs.stopped) == 1 {
bs.Logger.Error(fmt.Sprintf("Not starting %v -- already stopped", bs.name), "impl", bs.impl)
// revert flag
atomic.StoreUint32(&bs.started, 0)
return ErrAlreadyStopped
}
bs.Logger.Info(fmt.Sprintf("Starting %v", bs.name), "impl", bs.impl)
err := bs.impl.OnStart()

Therefore, calling IsRunning() can return true even though the service is not yet started (or partially started)

Copy link
Contributor

@xla xla left a comment

Choose a reason for hiding this comment

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

👍 :octocat: :shipit: 🍡

Simpler, faster, stronger!

@xla xla changed the title Make node respond to os interrupts while sleeping until genesis time node: Respond to os interrupts while sleeping until genesis time Sep 25, 2018
@xla xla changed the title node: Respond to os interrupts while sleeping until genesis time node: Respond always to OS interrupts Sep 25, 2018
@xla xla merged commit d12e55c into develop Sep 25, 2018
@xla xla deleted the 2434-unresponsive-node branch September 25, 2018 10:24
@xla xla mentioned this pull request Sep 25, 2018
1 task
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.

None yet

3 participants