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

balancer_by_lua_block : Reusing stale connection #65

Closed
rohitjoshi opened this issue Oct 20, 2016 · 5 comments
Closed

balancer_by_lua_block : Reusing stale connection #65

rohitjoshi opened this issue Oct 20, 2016 · 5 comments

Comments

@rohitjoshi
Copy link

Hello,
I am using balancer_by_lua for upstream routing which works great. We are seeing intermittent errors where nginx is caching the connection while upstream has already terminated.

See the below image. xxx.xxx.xxx.159 is OpenResty server and xxx.xxx.xxx.27 is upstream server.

upstream_stale_connection

Thanks,
Rohit Joshi

@agentzh
Copy link
Member

agentzh commented Oct 25, 2016

@rohitjoshi What's in your nginx error logs (assuming you are not setting the error log filter level too high)?

Usually such RSTs should be harmless since nginx will automatically retry a new connection for the current request.

@agentzh
Copy link
Member

agentzh commented Oct 25, 2016

@rohitjoshi The nginx core does check broken connections in the connection pool, but race conditions are inevitable in case the nginx just tries to use an in-pool connection before it can handle a read event for the connection termination request from the remote.

@rohitjoshi
Copy link
Author

The issue is due to AWS NAT gateway terminates connection after 5 minutes.

I am seeing below error in the error log.
' upstream prematurely closed connection while reading response header from upstream'
Nginx doesn't retry automatically. I had to enable next upstream on 502 for post requests.

@agentzh
Copy link
Member

agentzh commented Oct 25, 2016

@rohitjoshi Yes, you need to enable the next upstream mechanism.

@thibaultcha
Copy link
Member

Closing this and considering it answered. Latest Nginx versions also have keepalive_timeout and keepalive_requests to remedy such race-conditions.

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