-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
quick hack to prevent indefinite buildup of closenotify routines #2014
Conversation
Will this properly kill a connection that is legitimately still open? (It's good if it does, just wondering if it'd still leak, just the other way around.) |
it will kill an active connection, yes. The only good way to fix this is to fix close notify :/ |
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
ac5acc2
to
12dcb73
Compare
Actually this isn't a 'quick hack'. The timeout should exist but can be made longer when closenotifier is fixed. There is only one test for nonexisting hash so far, https://github.com/ipfs/go-ipfs/blob/792da9d87587e28d65b98a28fa4cc2d20388ccca/test/sharness/t0220-bitswap.sh#L15, and even here the timeout is explicitly specified. Also there should be a way to check for active connections, e.g. |
@@ -152,6 +153,9 @@ func (i internalHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |||
if cn, ok := w.(http.CloseNotifier); ok { | |||
go func() { | |||
select { | |||
case <-time.After(time.Minute * 30): | |||
// TODO: this is a hack to avoid these goroutines building up in memory | |||
log.Warning("TODO: close notify needs to be fixed") |
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.
what if a file is legitimately big enough + over a low bw conn to require 30min to stream? again, this needs to take into account the rate + progress. a timeout like this is ok when there havent been any bytes through (or too few)
closing in favor of #2032 |
I think a timeout is still required for |
@rht how do you distinguish (a) a nonexistent hash, (b) a hash normally available, just not now, (c) a hash hosted by a node very far away (latencies above 10s). i think the "what to do" really depends on use case.
i also think that making sure all hashes being resolved have a context tied to the client properly will solve most problems: the issue is that a client issues "get X" and disappears. the context should be cancelled when the client disappears. it's like |
Until we get closeNotify fixed, this will help prevent these goroutines from hanging forever and building up in memory.
License: MIT
Signed-off-by: Jeromy jeromyj@gmail.com