summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsasha@mysql.sashanet.com <>2001-04-03 08:28:28 -0600
committersasha@mysql.sashanet.com <>2001-04-03 08:28:28 -0600
commit1c216c4141c2a5f97ad8c1e0f079efc1a4050c6b (patch)
treeb44213f1b2f4f962dbb576602f348b3fb33c7447
parentb1bfac474845fdf40c423fe0660f5a747b97a264 (diff)
downloadmariadb-git-1c216c4141c2a5f97ad8c1e0f079efc1a4050c6b.tar.gz
sometimes the server lags behind the client on startup - to fix, if the initial connect fails, sleep and try again
before giving up
-rw-r--r--client/mysqltest.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c
index 019063b48a7..d354bbbca01 100644
--- a/client/mysqltest.c
+++ b/client/mysqltest.c
@@ -74,6 +74,11 @@
#define MAX_EXPECTED_ERRORS 10
#define QUERY_SEND 1
#define QUERY_REAP 2
+#define CON_RETRY_SLEEP 1 /* how long to sleep before trying to connect again*/
+#define MAX_CON_TRIES 2 /* sometimes in a test the client starts before
+ * the server - to solve the problem, we try again
+ * after some sleep if connection fails the first
+ * time */
static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
static char *db = 0, *pass=0;
@@ -931,6 +936,8 @@ int do_connect(struct st_query* q)
char* p=q->first_argument;
char buff[FN_REFLEN];
int con_port;
+ int i, con_error;
+
DBUG_ENTER("do_connect");
DBUG_PRINT("enter",("connect: %s",p));
@@ -961,8 +968,20 @@ int do_connect(struct st_query* q)
con_sock=fn_format(buff, con_sock, TMPDIR, "",0);
if (!con_db[0])
con_db=db;
- if (!mysql_real_connect(&next_con->mysql, con_host, con_user, con_pass,
- con_db, con_port, con_sock, 0))
+ con_error = 1;
+ for (i = 0; i < MAX_CON_TRIES; ++i)
+ {
+ if(mysql_real_connect(&next_con->mysql, con_host,
+ con_user, con_pass,
+ con_db, con_port, con_sock, 0))
+ {
+ con_error = 0;
+ break;
+ }
+ sleep(CON_RETRY_SLEEP);
+ }
+
+ if(con_error)
die("Could not open connection '%s': %s", con_name,
mysql_error(&next_con->mysql));