@@ -51,6 +51,21 @@ function connect_root(; db=nothing)
5151 end
5252end
5353
54+ function wait_for_connection (; db= nothing , timeout= 30.0 )
55+ start = time ()
56+ last_err = nothing
57+ while time () - start < timeout
58+ try
59+ return connect_root (; db= db)
60+ catch err
61+ last_err = err
62+ logline (" WAIT_CONNECTION db=" , db, " error=" , sprint (showerror, err))
63+ sleep (1 )
64+ end
65+ end
66+ error (" MySQL did not become ready: " , sprint (showerror, last_err))
67+ end
68+
5469function placeholders (n:: Integer )
5570 return join (fill (" ?" , n), " ," )
5671end
@@ -99,7 +114,7 @@ function run_case(conn, name::String, shape::Symbol, params; mysql_store_result:
99114end
100115
101116function prepare_database ()
102- conn = connect_root ()
117+ conn = wait_for_connection ()
103118 try
104119 version = DBInterface. execute (conn, " SELECT VERSION() AS version" ) |> Tables. columntable
105120 logline (" SERVER_VERSION " , only (version. version))
@@ -110,7 +125,7 @@ function prepare_database()
110125 DBInterface. close! (conn)
111126 end
112127
113- conn = connect_root (db= " issue236" )
128+ conn = wait_for_connection (db= " issue236" )
114129 DBInterface. execute (conn, " CREATE TABLE myTable (id BIGINT UNSIGNED NOT NULL PRIMARY KEY)" )
115130
116131 stmt = DBInterface. prepare (conn, " INSERT INTO myTable (id) VALUES (?)" )
0 commit comments