-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Panic on server shutdown #1504
Comments
Not sure if the first even has to be a panic, to be honest. Looks like nothing but a sanity check to me. |
hello @mpldr Can you provide a complete runnable code ? I would like to try to reproduce this problem in my computer. |
Sure, here you go: http://0x0.st/Hs5T.tzst It's not yet part of any repo, so a tarball is the best I can offer you right away :) |
The problem is that Line 2903 in 559d536
But then when the worker goroutine stops it also calls Close on the connection here: Line 238 in 404c8a8
We should somehow stop one of them from happening. I think I'm afraid I don't have time to investigate this further right now. I'll have another look in the future. |
Thinking of it, I more and more think this shouldn't be a panic but instead handled gracefully™ (which might mean discarding after logging in this case) |
* client: simplify (*HostClient).do() Remove an allocation in favour of deferring a call to release the response. * client: remove panic in dialAddr Return an error instead of panicking if the user supplied a nonsensical DialFunc. * compression: remove panic on invalid compression level If a compression level exceeding gzip's boundaries is provided, fasthttp will panic. Instead it would be better to handle this error for them by limiting it to the minimum or maximum value, depending on the direction the user has exceeded the limits. Clamp the value of gzip to always be between gzip.BestSpeed and gzip.BestCompression. * peripconn: remove panic on negative connection count When a negative count is reached when unregistering a connection, a panic is caused even though data-integrity is not at risk. Replace the panic() with a simple clamp on the value to ensure the value does not exceed it's expected lower bounds. References: #1504 * compress: remove error on failed nonblocking writes Since there is no way of handling or even logging non-critical errors in stateless non-blocking writecalls, just drop them and hope the user notices and tries again. * workerPool: remove panic on redundant Start and Stop calls Instead of panicking for invalid behaviour, it's preferable to just turn the function into a noop. * http: remove panic on invalid form boundary * http: remove panic on negative reads Since bufio already panics on negative reads, it is not necessary to do so as well. If the length is zero and for some reason no error is returned, readBodyIdentity and appendBodyFixedSize now errors in these cases. Link: https://github.com/golang/go/blob/851f6fd61425c810959c7ab51e6dc86f8a63c970/src/bufio/bufio.go#L246 * fs: remove panic on negative reader count When a negative count is reached when unregistering a reader, a panic is thrown even though data-integrity is not at risk. Replace the panic() with a simple clamp on the value to ensure the value does not exceed it's expected lower bounds. * server: remove panic in favour of a segfault Panicking with "BUG: " obscures the error. As the segfault causes a panic anyway, just let the chaos unfold. * server: remove panic in favour of returning an error Writing on a timed-out response is not endangering data integrity and just fails. * chore: add comments to all panics * chore: fix minor typo
Should be fixed in #1526 |
As mentioned in #1526 it now doesn't panic anymore. The underlying double close is not fixed. So not sure if this ticket should be renamed. |
I encounter this panic when shutting down the server.
The steps are:
Server setup/shutdown:
The panic I get is:
At times I also get this:
But the latter is only sometimes.
The text was updated successfully, but these errors were encountered: