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

gracefully shuts down bug. #958

Closed
alpha-baby opened this issue Feb 1, 2021 · 6 comments
Closed

gracefully shuts down bug. #958

alpha-baby opened this issue Feb 1, 2021 · 6 comments

Comments

@alpha-baby
Copy link
Contributor

when invocate func (s *Server) Shutdown() error, should return header: Connection: close

if you sure it's a bug, i will commit a PR to fix it.

@erikdubbelboer
Copy link
Collaborator

Good idea. I think here:

connectionClose = connectionClose || ctx.Response.ConnectionClose()

It should include || atomic.LoadInt32(&s.stop) == 1

Can you test this and make a pull request? Thanks.

alpha-baby pushed a commit to alpha-baby/fasthttp that referenced this issue Feb 2, 2021
@kirillDanshin
Copy link
Collaborator

hey @alpha-baby, thanks for your report.

I'm concerned this one could introduce bugs in case of fasthttp service being behind ALB, 'cause the client would close the connection to ALB, then open it again unnecessarily, which will cause a spike in load during rollouts. I'd prefer having this under an option

@erikdubbelboer
Copy link
Collaborator

@kirillDanshin good point I didn't think of that. @alpha-baby can you add an option to the Server struct for this. Something like CloseOnShutdown so the default is false which doesn't break anything for current users.

@alpha-baby
Copy link
Contributor Author

@kirillDanshin good point I didn't think of that. @alpha-baby can you add an option to the Server struct for this. Something like CloseOnShutdown so the default is false which doesn't break anything for current users.

Ok,tomorrow i will commit new code.

@alpha-baby
Copy link
Contributor Author

hey @alpha-baby, thanks for your report.

I'm concerned this one could introduce bugs in case of fasthttp service being behind ALB, 'cause the client would close the connection to ALB, then open it again unnecessarily, which will cause a spike in load during rollouts. I'd prefer having this under an option

before i commit this PR, tcp connection also will be close when you call func (s *Server) Shutdown() error.

Closing connection source code in here: https://github.com/valyala/fasthttp/blob/master/server.go#L2303

@erikdubbelboer
Copy link
Collaborator

The connections being closed is what is supposed to happen. What people might not want is the connection from the client to the loadbalancer being terminated as well if there is a loadbalancer.

erikdubbelboer added a commit that referenced this issue Feb 7, 2021
* fix gracefilly shutdown bug, issue #958

* fix golangci-lint

* add option: CloseOnShutdown into Sever

* Update server.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

* Update server.go

Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>

Co-authored-by: fujianhao3 <fujianhao3@jd.com>
Co-authored-by: Erik Dubbelboer <erik@dubbelboer.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants