Skip to content

Conversation

@dsaveliev
Copy link
Member

@dsaveliev dsaveliev commented Feb 26, 2019

Ignore disconnects when stopping node - fixes #367
This is a port of bitcoin/bitcoin#14670

This problem is related to the "stop" RPC call.
It turns out that sometimes the node stops before it sends the response.
That causes the client to retry the call and lead to "ConnectionRefusedError".

I found out that there is a fix in bitcoin repo (in master branch, actually), related to this bug.
In the nutshell, this changes remove forced exit of libevent loop, which allows
to process all the requests gracefully.

Test feature_shutdown.py wasn't ported because it introduces a bug bitcoin/bitcoin#14670 (comment)
The "improvement" bitcoin/bitcoin#14958 requires RPC method "getrpcinfo" which isn't ported from the bitcoin codebase yet.

There are other floating tests with a similar error (ConnectionRefusedError):
fixes #373
fixes #484
fixes #544

Test runs:
rpc_fundrawtransaction.py - https://travis-ci.com/dsaveliev/unit-e/builds/102691551
feature_notifications.py - https://travis-ci.com/dsaveliev/unit-e/builds/102777885
mempool_packages.py - https://travis-ci.com/dsaveliev/unit-e/builds/102779373
feature_cltv.py - https://travis-ci.com/dsaveliev/unit-e/builds/102784432

Signed-off-by: Dmitry Saveliev [email protected]

@dsaveliev dsaveliev added the wip Work in progress which is not supposed to be merged yet label Feb 26, 2019
@dsaveliev dsaveliev added this to the 0.1 milestone Feb 26, 2019
@dsaveliev dsaveliev self-assigned this Feb 26, 2019
@scravy
Copy link
Member

scravy commented Feb 26, 2019

@dsaveliev There's a new github feature for pull requests. When opening one there is a drop down menu in the green "create pull request" button which allows you to open a "draft" pull request. Feel free to make use of it in the future, it's exactly for this purpose (our very own WIP label stems from a time before that)

@dsaveliev dsaveliev force-pushed the fix-node-stop-rpc-call branch 3 times, most recently from 14d9038 to 32d95eb Compare February 26, 2019 17:11
@dsaveliev dsaveliev changed the title Ignore disconnections when stopping node Ignore disconnects when stopping node Feb 26, 2019
@dsaveliev dsaveliev force-pushed the fix-node-stop-rpc-call branch 2 times, most recently from 576fd68 to 22f6210 Compare February 28, 2019 09:12
@dsaveliev dsaveliev added bug A problem of existing functionality and removed wip Work in progress which is not supposed to be merged yet labels Feb 28, 2019
Sending the header "Connection: close" makes libevent close persistent
connections (implicit with HTTP 1.1) which cleans the event base when
shutdown is requested.

Signed-off-by: Dmitry Saveliev <[email protected]>
This (almost) move only ensures the event base loop doesn't exit before
HTTP worker threads exit. This way events registered by HTTP workers are
processed and not discarded.

Signed-off-by: Dmitry Saveliev <[email protected]>
Let event base loop exit cleanly by processing all active and pending
events. The call is no longer necessary because closing persistent
connections is now properly handled.

Signed-off-by: Dmitry Saveliev <[email protected]>
Let HTTP connections to timeout due to inactivity.
Let all remaning connections finish sending the response and close.

Signed-off-by: Dmitry Saveliev <[email protected]>
Signed-off-by: Dmitry Saveliev <[email protected]>
Signed-off-by: Dmitry Saveliev <[email protected]>
@dsaveliev dsaveliev force-pushed the fix-node-stop-rpc-call branch from 22f6210 to e9adf37 Compare February 28, 2019 09:39
@scravy scravy requested a review from a team February 28, 2019 10:31
@dsaveliev dsaveliev requested a review from thothd February 28, 2019 12:38
Copy link
Member

@scravy scravy left a comment

Choose a reason for hiding this comment

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

utACK 5f973f8

Looks good to me. I compared it with the bitcoin pull, and this is pretty much the same fix, minus some changes as it's from different branches, but that's fine.

@scravy
Copy link
Member

scravy commented Feb 28, 2019

@dsaveliev If you put fixes #367 (instead of just refs ...) into the description the ticket will be closed automatically when merging this pull request. It's nice as it's also advertised in the ui as "this ticket will be closed by this pull request" etc.

Copy link
Member

@thothd thothd left a comment

Choose a reason for hiding this comment

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

Awesome, would be glad to see these floating tests bold green.
@dsaveliev it's probably fixing bunch of more tests than just #367 ?

@dsaveliev
Copy link
Member Author

dsaveliev commented Feb 28, 2019

@dsaveliev it's probably fixing bunch of more tests than just #367 ?

I think this might be so. Right now I'm running through the floating tests in order to find similar cases.

@AM5800
Copy link
Member

AM5800 commented Feb 28, 2019

utACK 5f973f8

Congratulations with the first PR =)

@kostyantyn
Copy link
Member

I am not sure we should modify commit messages we take from Bitcoin. I didn't check them all but I see we added Signed-off-by block. I think we should just take such commits as is.

@scravy
Copy link
Member

scravy commented Feb 28, 2019

Please do not squash merge this, I will merge-merge this.

@thothd
Copy link
Member

thothd commented Feb 28, 2019

I am not sure we should modify commit messages we take from Bitcoin. I didn't check them all but I see we added Signed-off-by block. I think we should just take such commits as is.

@kostyantyn maybe explain what's the issue with it? I think you've done the same for the ECMH commit

@dsaveliev
Copy link
Member Author

I am not sure we should modify commit messages we take from Bitcoin. I didn't check them all but I see we added Signed-off-by block. I think we should just take such commits as is.

The problem is that DCO check doesn't pass without signing every single commit, so I was forced to do this.

@scravy
Copy link
Member

scravy commented Feb 28, 2019

The problem is that DCO check doesn't pass without signing every single commit, so I was forced to do this.

That's just partially true. For exactly these cases you can go into the failing check (follow the "Details" link) and "Set DCO to pass" (there's a button).

@kostyantyn
Copy link
Member

It's enough to cherry-pick commits. git cherry-pick <commit hash> and push to the branch. Here I see that we also edited commit messages and added the Signed-off-by. I'd suggest just keep such messages are is, without editing them and then add new commits on top of them to correct what is needed.

@cornelius
Copy link
Member

I am not sure we should modify commit messages we take from Bitcoin. I didn't check them all but I see we added Signed-off-by block. I think we should just take such commits as is.

Adding the Signed-off-by trailer is fine, I think. As a committer you sign off on the patch of the author. This implies that you have checked that the patch is ok to apply to unit-e. That is actually useful information.

Copy link
Member

@kostyantyn kostyantyn left a comment

Choose a reason for hiding this comment

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

utACK 5f973f8

As soon as we agree on commit messages as I see we didn't do that for other such PRs.

@thothd
Copy link
Member

thothd commented Feb 28, 2019

It's enough to cherry-pick commits. git cherry-pick <commit hash> and push to the branch. Here I see that we also edited commit messages and added the Signed-off-by. I'd suggest just keep such messages are is, without editing them and then add new commits on top of them to correct what is needed.

I think @dsaveliev cherry picked them, just had to adjust the code a bit since it's quite a recent Bitcoin code
But wherever it’s not the case I agree we shouldn’t touch the commits

@dsaveliev
Copy link
Member Author

@thothd @scravy - similar floating tests were added to the PR description.

@scravy
Copy link
Member

scravy commented Feb 28, 2019

Great, I will merge-merge this then.

@scravy scravy merged commit 6753dac into dtr-org:master Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug A problem of existing functionality

Projects

None yet

7 participants