I can not and will not make an absolute recommendation to keep or lose
the mutex before I performed a full code review. IMHO, the final stages of
a project is one of the worst times to be making this kind of decision as
it could impact so much work already accomplished.
If you are certain that each connection can only be used by one
thread/process at a time, then you should not need to synchronize
(serialize) access to any connection. Connection pooling IS NOT connection
It sounds to me that the previous version of your application shared a
single connection between several threads and required a transaction-level
mutex to ensure proper SQL command serialization. You probably do not
need that now as you are not _sharing_ a single common connection between
more than one execution at a time. If you DO share a connection between
two or more threads or processes, you will need to keep the mutex to keep
one thread from clobbering the SQL being executed by the other.
Does MySQL or ODBC handle the mutex? No, that is part of your execution
environment (usually handled by the OS). Will ODBC pool connections? Yes,
if you allow it to do so. MySQL keeps all connections separated from each
other until the point data is committed to the database (transactional
boundaries). How your application uses transactions is up to you. Under
most circumstances, what one connection is doing is invisible to what
another connection is doing up to the point at which one of them commits
their changes to the database. Then those changes may, depending on your
transaction isolation level, become instantly visible to the other
connection or not. As I said, it all depends.
If each thread/process establishes its own connection to the database
server, you are in a situation (from the point of view of the database
server) identical to what would be happening if all of your processes were
connecting in from different physical machines. If you need a mutex to
serialize access under that scenario, then you should keep it.
Unimin Corporation - Spruce Pine
<lakshmi.narasimharao@stripped> wrote on 08/30/2005 10:56:20 AM:
> Hi Green,
> We are at the last stage of the project (migration from Oracle to
> MySQL). We are demanded to adopt the MYODBC as a customer requrement.
> As mutex was implemented for oracle so it is there in our code. Now we
> are thinking to remove that because application level we have connection
> So, please advise us in this case can we remove the mutex?.
> I beleive that in the ODBC and in MySQL mutex will be handled
> automatically, right?.