-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
quic: rcmgr: Fix connection accounting #2025
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Do we have the same problem in the WebTransport transport?
@@ -84,7 +82,7 @@ func (l *listener) Accept() (tpt.CapableConn, error) { | |||
} | |||
} | |||
|
|||
func (l *listener) setupConn(qconn quic.Connection) (*conn, error) { | |||
func (l *listener) setupConn(qconn quic.Connection) (_c *conn, _err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the _
needed? I've never seen this pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed, I don't want to shadow or deal with shadowed vars. I also don't want this to be used in the body of the function.
I also want to avoid the use of the named return values except for this deferred error handling.
If you have a better naming suggestion I'm open to it.
There's a flaky rcmgr test:
|
Thanks @MarcoPolo . Do you think this would have impacted System.ConsInbound? If so, I agree it would be nice to include in Kubo 0.18.1 . If not, I think it can wait. |
WebTransport doesn't use the err defer pattern but looks okay. |
Looking at the data and the code, conns inbound should be safe from this miscount. |
It looks like this won't affect the code path that Kubo is using for its resource management in v0.18. Cutting and bubbling up a patch release is pretty low overhead though, so we should consider doing it anyway. This has confused Antonio and it has come up in https://github.com/protocol/bifrost-infra/issues/2308. We might be able to avoid some spurious bug reports if we get this fix out asap. |
The quic transport didn't end the connection reservation in some error cases. The fix here is to use the "err defer" pattern to handle all error cases by checking for errors in a defer statement and finishing the scope then. This pattern is more resilient to future changes since future code doesn't have to remember to free resources on every err return statement.
Tested by having Kubo run for a while.
Before:
After:
This was debugged with this commit. It would give some memory to the connections in the swarm and then print out any connection scopes that didn't have memory and were not done. This meant that they were created but not passed down to the swarm and not finished.