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

Fix server hang when trying to stop a server with active connections with event notifications #8432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TreeHunter9
Copy link
Contributor

@TreeHunter9 TreeHunter9 commented Feb 7, 2025

The reason for the hang is that we handle port_async in a strange way. When we create it in aux_request() it is added to chain of client ports (port_clients) via alloc_port(), but is not added to inet_ports. inet_ports used in PortsCleanup::closePorts() when we start shutdown server to close ports that we currently have. So, after closing all client ports, except port_async, we start looping over these active ports in select_multi(), hoping to get some data from them. This is happens because port_async is presented in port_clients chain and has port_state = PENDING.
My fix for this problem is to close port_async when we close it's parent port.

The hang can be reproduced by running example/api/api16 and making one more additional connection to the database, then try to kill the server, it will hang with inability to receive new connections, it can only be stopped with kill -9.

This bug can also be reproduced in v5.0, I haven't tested it in older versions, but it seems the code is the same.

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

Successfully merging this pull request may close these issues.

1 participant