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

xud doesn't shut down gracefully with active rpc streaming calls #699

Closed
offerm opened this issue Nov 21, 2018 · 14 comments · Fixed by #717
Closed

xud doesn't shut down gracefully with active rpc streaming calls #699

offerm opened this issue Nov 21, 2018 · 14 comments · Fixed by #717
Assignees
Labels
bug Something isn't working
Milestone

Comments

@offerm
Copy link
Contributor

offerm commented Nov 21, 2018

xucli shutdown does not bring the process down and does not close the active peer connections.

@sangaman sangaman added the bug Something isn't working label Nov 23, 2018
@sangaman
Copy link
Collaborator

Can you provide more details/steps to reproduce? If I start up xud, connect to peers, and then run xucli shutdown it does end the process. Do you see different?

@offerm
Copy link
Contributor Author

offerm commented Nov 23, 2018 via email

@sangaman
Copy link
Collaborator

Thanks, I do see at least one thing that could keep us from ending the process (the peer reconnection timers) so that might be the issue here.

@offerm
Copy link
Contributor Author

offerm commented Nov 23, 2018

This is what I find in the log:

11/23/2018, 6:05:52 AM [GLOBAL] info: XUD is shutting down
11/23/2018, 6:05:52 AM [RPC] info: gRPC Web API proxy stopped listening

Easy to reproduce on test1.xud
~

@offerm
Copy link
Contributor Author

offerm commented Nov 23, 2018

You need to have a peer connected to the node to see the problem.

@offerm
Copy link
Contributor Author

offerm commented Nov 23, 2018

Also note that it is not working also with master.

sangaman added a commit that referenced this issue Nov 23, 2018
This properly cancels the timer to retry a connection to a peer when
the peer is closed. Not canceling the timer could interfere with
gracefully shutting down `xud`, as the process would continue waiting
for the timer after.

Fixes #699.
sangaman added a commit that referenced this issue Nov 23, 2018
This properly cancels the timer to retry a connection to a peer when
the peer is closed. Not canceling the timer could interfere with
gracefully shutting down `xud`, as the process would continue waiting
for the timer.

Fixes #699.
@ghost ghost assigned sangaman Nov 23, 2018
@ghost ghost added the in progress label Nov 23, 2018
@sangaman
Copy link
Collaborator

Can you retry your test with the branch from #701?

@offerm
Copy link
Contributor Author

offerm commented Nov 23, 2018

Not solved. Suggest you start by reproducing the problem.

@sangaman
Copy link
Collaborator

Ok I'll have to revisit tomorrow. It's not as simple as having a peer connected as my first try to reproduce did not have this issue even with peers connected. Can you share the full log including all peers you connected to? Are you just starting xud and then shutting down, or doing anything else in between?

@kilrau kilrau added this to the 1.0.0-alpha.6 milestone Nov 26, 2018
@kilrau kilrau changed the title xucli shutdown xucli 'shutdown' doesn't shut down xud process Nov 26, 2018
@offerm
Copy link
Contributor Author

offerm commented Nov 29, 2018

Log file:

11/29/2018, 4:05:53 PM [P2P] verbose: received 10 orders from 03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.86,"quantity":0.003,"isBuy":true,"hold":0,"id":"e16cbf80-f2d0-11e8-9339-79fb57d4a049","initialQuant
ity":0.003,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553591}
11/29/2018, 4:05:53 PM [P2P] verbose: received 0 nodes (0 new) from 03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.87,"quantity":0.0025,"isBuy":true,"hold":0,"id":"e16d34b0-f2d0-11e8-9339-79fb57d4a049","initialQuan
tity":0.0025,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553592}
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.88,"quantity":0.002,"isBuy":true,"hold":0,"id":"e16d82d0-f2d0-11e8-9339-79fb57d4a049","initialQuant
ity":0.002,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553593}
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.89,"quantity":0.0015,"isBuy":true,"hold":0,"id":"e16dd0f0-f2d0-11e8-9339-79fb57d4a049","initialQuan
tity":0.0015,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553594}
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.9,"quantity":0.001,"isBuy":true,"hold":0,"id":"e16df801-f2d0-11e8-9339-79fb57d4a049","initialQuanti
ty":0.001,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553594}
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.14,"quantity":0.003,"isBuy":false,"hold":0,"id":"e16bae10-f2d0-11e8-9339-79fb57d4a049","initialQuan
tity":0.003,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553595}
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.1,"quantity":0.001,"isBuy":false,"hold":0,"id":"e16e4620-f2d0-11e8-9339-79fb57d4a049","initialQuant
ity":0.001,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553596}
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.11,"quantity":0.0015,"isBuy":false,"hold":0,"id":"e16e6d31-f2d0-11e8-9339-79fb57d4a049","initialQua
ntity":0.0015,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553596}
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.12,"quantity":0.002,"isBuy":false,"hold":0,"id":"e16ebb50-f2d0-11e8-9339-79fb57d4a049","initialQuan
tity":0.002,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553597}
11/29/2018, 4:05:53 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.13,"quantity":0.0025,"isBuy":false,"hold":0,"id":"e16ee261-f2d0-11e8-9339-79fb57d4a049","initialQua
ntity":0.0025,"peerPubKey":"03fd337659e99e628d0487e4f87acf93e353db06f754dccc402f2de1b857a319d0","createdAt":1543507553597}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.14,"quantity":0.003,"isBuy":false,"localId":"a87cc550-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"a
87cc550-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.003,"createdAt":1543507557925}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.86,"quantity":0.003,"isBuy":true,"localId":"a87dd6c0-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"a8
7dd6c0-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.003,"createdAt":1543507557932}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.87,"quantity":0.0025,"isBuy":true,"localId":"a87e4bf0-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"a
87e4bf0-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.0025,"createdAt":1543507557935}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.88,"quantity":0.002,"isBuy":true,"localId":"a87e9a10-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"a8
7e9a10-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.002,"createdAt":1543507557937}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.89,"quantity":0.0015,"isBuy":true,"localId":"a87ee830-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"a
87ee830-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.0015,"createdAt":1543507557939}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":0.9,"quantity":0.001,"isBuy":true,"localId":"a87f3650-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"a87
f3650-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.001,"createdAt":1543507557941}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.1,"quantity":0.001,"isBuy":false,"localId":"a87f8470-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"a8
7f8470-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.001,"createdAt":1543507557943}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.11,"quantity":0.0015,"isBuy":false,"localId":"a87fab81-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"
a87fab81-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.0015,"createdAt":1543507557944}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.12,"quantity":0.002,"isBuy":false,"localId":"a87ff9a0-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"a
87ff9a0-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.002,"createdAt":1543507557946}
11/29/2018, 4:05:57 PM [ORDERBOOK] debug: order added: {"pairId":"LTC/BTC","price":1.13,"quantity":0.0025,"isBuy":false,"localId":"a88047c0-f3f0-11e8-b91a-1bbeae0a7374","hold":0,"id":"
a88047c0-f3f0-11e8-b91a-1bbeae0a7374","initialQuantity":0.0025,"createdAt":1543507557948}
11/29/2018, 4:06:08 PM [P2P] debug: Connected pre-handshake to peer 199.203.79.137:64348
11/29/2018, 4:06:08 PM [P2P] verbose: received hello packet from 199.203.79.137:64348: {"version":"1.0.0-alpha.4","pairs":["LTC/BTC"],"nodePubKey":"0343d327538650a721fa193aaf8bfb7cc9a2
9a5017a74d0e03a73b74ff1660067d","lndbtcPubKey":"0335e67026ea6aa687f2c7858b40ffac0354c726b30795b86fe958e3f663c77a31","lndltcPubKey":"020944f8cc2e9b96fa86808226e8450ebbf14b2d825477a45d0e
166adfee9931ba","addresses":[]}
11/29/2018, 4:06:08 PM [P2P] verbose: opened connection to 0343d327538650a721fa193aaf8bfb7cc9a29a5017a74d0e03a73b74ff1660067d at 199.203.79.137:64348
11/29/2018, 4:06:09 PM [P2P] verbose: received 0 orders from 0343d327538650a721fa193aaf8bfb7cc9a29a5017a74d0e03a73b74ff1660067d
11/29/2018, 4:06:09 PM [P2P] verbose: received 0 nodes (0 new) from 0343d327538650a721fa193aaf8bfb7cc9a29a5017a74d0e03a73b74ff1660067d
11/29/2018, 4:06:31 PM [GLOBAL] info: XUD is shutting down
11/29/2018, 4:06:31 PM [RPC] info: gRPC Web API proxy stopped listening

@offerm
Copy link
Contributor Author

offerm commented Nov 29, 2018

@sangaman The problem is due to a stream connection which is open to the server.

You can reproduce by the following:

  1. start xud
  2. xucli streamorders &
3. xucli shutdown

The process will not exit until you kill

@sangaman
Copy link
Collaborator

Thanks for figuring that out! I was stuck since I'd never been calling streamorders - that makes sense. I'll open a PR for a fix.

sangaman added a commit that referenced this issue Nov 30, 2018
This tracks all active streaming gRPC calls and closes them when the
gRPC server is shut down. Previously, active streaming calls would
prevent `xud` from shutting down gracefully.

Fixes #699.
@offerm
Copy link
Contributor Author

offerm commented Nov 30, 2018 via email

@offerm
Copy link
Contributor Author

offerm commented Nov 30, 2018

Yes.
If a node has an incoming connection, shutdown will not work.
@sangaman

sangaman added a commit that referenced this issue Dec 2, 2018
This tracks all active streaming gRPC calls and closes them when the
gRPC server is shut down. Previously, active streaming calls would
prevent `xud` from shutting down gracefully.

Fixes #699.
@ghost ghost removed the in progress label Dec 2, 2018
@sangaman sangaman changed the title xucli 'shutdown' doesn't shut down xud process xud doesn't shut down gracefully with active rpc streaming calls Dec 2, 2018
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 a pull request may close this issue.

3 participants