Welcome! Log In Create A New Profile

Advanced

Quick successive reload makes "bind () xxxx failed, Address already in use" error

Posted by Anonymous User 
Hi,



I have a script runs two successive reloads, the first one is to remove a listen port from the stream block, and the second one is to add the same port back to the stream block. It is observed that most time the script would run into "bind() xxxx failed, Address already in use" error. After putting a sleep 1 in between these two reloads I never get that error again.


So I guess the listening socket was not released in the time the second reload was issued?


How the listening socket is getting released during reload?


In this case, how to ensure that we can safely trigger the second reload other than sleep?






br,


Allen_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Kill old processes first, then start new processes.

On Wed, Jan 24, 2018 at 11:13 AM, <[email protected]> wrote:

> Hi,
>
> I have a script runs two successive reloads, the first one is to remove a
> listen port from the stream block, and the second one is to add the same
> port back to the stream block. It is observed that most time the script
> would run into "bind() xxxx failed, Address already in use" error. After
> putting a sleep 1 in between these two reloads I never get that error
> again.
>
> So I guess the listening socket was not released in the time the second
> reload was issued?
>
> How the listening socket is getting released during reload?
>
> In this case, how to ensure that we can safely trigger the second reload
> other than sleep?
>
>
> br,
>
> Allen
>
>
>
>
>
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Hello!

> I have a script runs two successive reloads, the first one is to remove a
listen port from the stream block, and the second one is to add the same
port back to the stream block. It is observed that > most time the script
would run into "bind() xxxx failed, Address already in use" error. After
putting a sleep 1 in between these two reloads I never get that error
again.

How does you send “reload” command? Through the nginx -s reload or sending
signal to the master process directly?

> So I guess the listening socket was not released in the time the second
reload was issued?

> How the listening socket is getting released during reload?

The old unnecessary listening sockets will be closed after nginx master
process opens the new listening sockets.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
If you search in Google

detect a IP port is in use in linux

you can find several ways to detect in the port is in use, for Windows and
Unix


-
https://www.cyberciti.biz/faq/unix-linux-check-if-port-is-in-use-command/
-
https://askubuntu.com/questions/278448/how-to-know-what-program-is-listening-on-a-given-port

Kindl regards,

Oscar

https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
Virus-free.
www.avast.com
https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Wed, Jan 24, 2018 at 8:01 AM, <[email protected]> wrote:

> The downtime is critical, we cannot take "Kill and Start process"
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



--
Oscar Fernandez Sierra
oscaretu@gmail.com
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
This is the forever loop that it it running in the script






for {


nginx -s reload //without the port


nginx -s reload //with the port


}






I found there was a transient that both the master process and the newly forked worker were listening the same port, I am not sure if this mgiht cause the "bind" error.


Another fact is that the port is listening after the "bind" error was occurring, so this was not due to the "delete" was not completed that makes the "add" not success.


I am wondering how this "bind" error happens?






Br,


Allen_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
On Wed, Jan 24, 2018 at 11:13:54AM +0800, he.hailong5@zte.com.cn wrote:

Hi there,

> I have a script runs two successive reloads, the first one is to remove a listen port from the stream block, and the second one is to add the same port back to the stream block.

Why?

If it is "I want to see what happens when I do that", that's perfectly
fine; carry on with the research.

If it is "I want to achieve some other objective, and this is a step
that I think is necessary", then perhaps there is an alternative way to
achieve that objective.

Cheers,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login