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

Handle graceful shutdown on TransportUseClosedError. #1065

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

AlejandroCabeza
Copy link
Collaborator

fixes: #1007

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 22.22222% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 82.53%. Comparing base (ca01ee0) to head (3e56745).
Report is 2 commits behind head on unstable.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           unstable    #1065      +/-   ##
============================================
- Coverage     82.81%   82.53%   -0.28%     
============================================
  Files            91       91              
  Lines         15750    15822      +72     
============================================
+ Hits          13043    13059      +16     
- Misses         2707     2763      +56     
Files Coverage Δ
libp2p/switch.nim 88.61% <22.22%> (-3.14%) ⬇️

... and 7 files with indirect coverage changes

lchenut
lchenut previously approved these changes Mar 15, 2024
Copy link
Contributor

@lchenut lchenut left a comment

Choose a reason for hiding this comment

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

LGTM

libp2p/switch.nim Outdated Show resolved Hide resolved
Copy link
Contributor

@diegomrsantos diegomrsantos left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor request. It'd be great if we could add a test too.

libp2p/switch.nim Outdated Show resolved Hide resolved
@AlejandroCabeza
Copy link
Collaborator Author

LGTM, just a minor request. It'd be great if we could add a test too.

That's a good idea, but it might be a tad too hard for me:
Can you point me to an already existing test I can use as template where accept is being tested/called? Also, I don't know how to raise the TransportUseClosedError which is necessary for the test, or how to mock it, for that matter.

Otherwise, this might be too time-consuming (for me).

@@ -273,11 +278,13 @@ proc accept(s: Switch, transport: Transport) {.async.} = # noraises
except CancelledError as exc:
trace "releasing semaphore on cancellation"
upgrades.release() # always release the slot
except TransportUseClosedError:
trace "Graceful shutdown in accept loop, exiting"
Copy link
Contributor

Choose a reason for hiding this comment

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

we can use the same as below "Exception in accept loop, exiting", exc = exc.msg

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't you think that might trigger the same reactions, from users, that @cheatfate was mentioning in the issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the issue was about the error log level. We can keep the one you used, my comment was about the rest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems to me that it makes sense for the others to still spit error, as long as it's an actual error. The issue, as I understood, is it was logging it as an error something that wasn't an actual error, hence confusing people.

Copy link
Contributor

@diegomrsantos diegomrsantos Mar 18, 2024

Choose a reason for hiding this comment

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

Users aren't supposed to use trace unless they are trying to debug an issue. That was precisely my intention suggesting "Exception in accept loop, exiting", exc = exc.msg, adding more useful info to the log, especially the exception msg.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue might be fixed by #1095 (comment). I'm tempted to close this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we test if it actually has been fixed? If yes, let's close this PR and link 1095 in the close message.

Copy link
Contributor

Choose a reason for hiding this comment

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

At the moment, I don't know how to reproduce it, if it hasn't been fixed yet.

@diegomrsantos
Copy link
Contributor

If testing it is too time consuming, or not even possible, that's fine.

@kaiserd
Copy link
Collaborator

kaiserd commented May 2, 2024

What is the status here?

@diegomrsantos diegomrsantos force-pushed the fix/issue/1007-graceful-shutdown branch from ceabad6 to 453bcc6 Compare June 25, 2024 11:29
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 22.22222% with 7 lines in your changes missing coverage. Please review.

Project coverage is 84.53%. Comparing base (02c96fc) to head (453bcc6).
Report is 30 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1065      +/-   ##
==========================================
- Coverage   84.53%   84.53%   -0.01%     
==========================================
  Files          91       92       +1     
  Lines       15517    16414     +897     
==========================================
+ Hits        13118    13875     +757     
- Misses       2399     2539     +140     
Files Coverage Δ
libp2p/switch.nim 89.28% <22.22%> (-2.43%) ⬇️

... and 77 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Pipeline
Development

Successfully merging this pull request may close these issues.

Graceful shutdown process reported as error in logs.
6 participants