Bug #15591 Occasional test suite abort due to port in use
Submitted: 8 Dec 2005 15:21 Modified: 4 Jan 2006 18:05
Reporter: Ingo Strüwing Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.0.19-pre OS:Linux (Linux)
Assigned to: Ingo Strüwing CPU Architecture:Any

[8 Dec 2005 15:21] Ingo Strüwing
Description:
This bug is barely repeatable.
It happens occasionally on very busy Linux systems.
I analyzed it when it happened last to me.
The cause is quite clear and a possible solution is attached (/will be committed soon).

How to repeat:
Run the test suite on a very busy Linux system with make test-force.
(I always use -debug-max builds, but I don't think this is required here.)

*If* the bug happens, it shows up as so:

some test                     [ pass ]
ERROR: /some_path/mysql-test/var/run/master.pid1 was not created in 400 seconds;  Aborting
make: *** [test-force] Error 1

Scan the error log files for "Can't start server: Bind on TCP/IP port: Address already in use"
I found it in mysql-test/var/log/master.err1:

051208  3:33:53 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
051208  3:33:53 [ERROR] Do you already have another mysqld server running on port: 40961 ?
051208  3:33:53 [ERROR] Aborting

Suggested fix:
In sql/mysqld.cc:server_init() retry the bind() to the port, if it fails with EADDRINUSE.

I will soon commit a changeset for this bug (hoping that the bugs database references the patch as it does for "in-progress" bugs). It does not break the system, but I did not yet find the "Note" in any of my error logs after the test runs with this patch.
[8 Dec 2005 15:25] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43
[28 Dec 2005 19:31] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/448
[29 Dec 2005 19:57] Ingo Strüwing
There is now a  new server option --port-open-timeout=# 
    Maximum time in seconds to wait for the port to become
    free. (Default: no wait)

This option is used in the test suite mysql-test-run.sh.

Pushed to 5.0.19, 5.1.5.
[4 Jan 2006 18:05] Paul DuBois
Noted in 5.0.19, 5.1.5 changelogs, and in
mysqld options section.