List:Commits« Previous MessageNext Message »
From:ingo Date:December 8 2005 3:24pm
Subject:bk commit into 5.0 tree (ingo:1.1984) BUG#15591
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of mydev. When mydev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1984 05/12/08 16:24:46 ingo@stripped +1 -0
  Bug#15591 Occasional test suite abort due to port in use
  Retry to bind the TCP port if it fails with EADDRINUSE.

  sql/mysqld.cc
    1.522 05/12/08 16:24:41 ingo@stripped +20 -2
    Bug#15591 Occasional test suite abort due to port in use
    Retry to bind the TCP port if it fails with EADDRINUSE.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ingo
# Host:	chilla.local
# Root:	/home/mydev/mysql-5.0-bug10932

--- 1.521/sql/mysqld.cc	2005-12-04 19:55:16 +01:00
+++ 1.522/sql/mysqld.cc	2005-12-08 16:24:41 +01:00
@@ -1357,7 +1357,10 @@
   struct sockaddr_un	UNIXaddr;
 #endif
   int	arg=1;
+  int   ret;
+  int   retry;
   DBUG_ENTER("server_init");
+  LINT_INIT(ret);
 
   set_ports();
 
@@ -1383,8 +1386,23 @@
     */
     (void) setsockopt(ip_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,sizeof(arg));
 #endif /* __WIN__ */
-    if (bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr),
-	     sizeof(IPaddr)) < 0)
+    /*
+      Sometimes the port is not released fast enough when stopping and
+      restarting the server. This happens quite often with the test suite
+      on busy Linux systems. Retry to bind the address at these intervals:
+      Sleep intervals: 1, 2, 4,  6,  9, 13, 17, 22
+      Retry at second: 1, 3, 7, 13, 22, 35, 52, 74
+      (Important TCP timeouts are at 30 and 60 seconds.)
+    */
+    for (retry= 1; retry <= 8; retry++)
+    {
+      if ((ret= bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr),
+                     sizeof(IPaddr)) >= 0) || (socket_errno != EADDRINUSE))
+        break;
+      sql_print_information("Retrying bind on TCP/IP port %u", mysqld_port);
+      sleep(retry * retry / 3 + 1);
+    }
+    if (ret < 0)
     {
       DBUG_PRINT("error",("Got error: %d from bind",socket_errno));
       sql_perror("Can't start server: Bind on TCP/IP port");
Thread
bk commit into 5.0 tree (ingo:1.1984) BUG#15591ingo8 Dec