[odb-users] Configure MySQL client connection

Boris Kolpackov boris at codesynthesis.com
Thu Jan 14 11:56:19 EST 2016


Hi Aarón,

Aarón Bueno Villares <abv150ci at gmail.com> writes:

> Is it that scene likely, or the internal behaviour of ODB works differently
> as I've depicted?

Here is how ODB does it: When one of the (low-level) MySQL operations on
a connection fails, before throwing a corresponding exception, ODB checks
whether the error code indicates the connection is no loner usable and, if
so, marks it as failed. You can check if a connection has been marked as
failed with connection::failed() predicate.

When the connection is returned to the connection_pool (i.e., there are
no more connection_ptr instances pointing to it), the pool checks if it
is failed. If it is still ok, then it is added back to the pool to be
reused. If it is failed, then it is simply destroyed.

For MySQL, there is also support for pinging the connection which the
pool does by default just before returning the connection to the
requester (see mysql::connection::ping()).

So, in your situation, if you have a connection_ptr instance pointing
to a failed connection and you keep trying to perform transactions on
this connection, you will keep getting the exception.

Boris



More information about the odb-users mailing list