Garage pool, prepared statements and DB connection failures

Skip to first unread message

Holger Freyther

Aug 30, 2015, 9:42:00 AM8/30/15
to DBXTalk

first of all thank you for Garage(-MySQL) it has helped me a lot in a project. I have some questions for corner cases.

My application has a long-standing MySQL connection so the danger is that it is actually dead when I want to use
it. So my code is doing something like:

      connection execute: 'SELECT 1+2'.
    ] on: Error do: [:err |].

    connection isConnected ifFalse: [
         connection connect].

Now I had something odd. I think I ended up in a case where for one MySQL request.. and failures.. I actually read
the result of the previous query. This means that code that tried to use 'atName:' of the result set failed miserably
and the issue seemed to have continued. I have modified the code my client code in two ways:

* In case a failure occurs I don't go through >>#close but get theStream of the netSession to close it directly. There is no point in sending a quit.
* I re-create the GADriver instead of calling >>#connect again

Somehow I think that my application is not that special in that regard and it would be nice if such and similar
features could go into the GAConnectionPool.

* GAConnectionPool>>#withConnectionDo: to avoid get/put connection
* Connections are validated only on returning connection but not when getting one.
* How would you use the GAConnectionPool with a prepared statement? E.g. like the validation block you could create a
>>#prepareBlock: that is executed when a new connection is created but where would you store the handles?
* Handling of ConnectionTimedOut? (e.g. validation fails and no new connection can be created?) E.g. on transient
failures (networking, mysqld restart, overload)?

Reply all
Reply to author
0 new messages