António Santos wrote:
>
> This happened when I was using transactions but then I removed the use
> of transactions and I get the same result.
> Do anyone know why this is happening? I have a mutex that assures that
> two threads do not affect the same rows at the same time.
First, I want to point out that this error comes from the MySQL server.
MySQL++ is only reporting it.
A Google search for ER_LOCK_DEADLOCK (the underlying MySQL error code)
says there are many more causes for this error than trying to modify
rows at the same time.
Rather than try to fight all of these cases, why not follow the advice
in the MySQL++ user manual, and use a separate Connection from each
thread? You cannot cause a MySQL server deadlock in this situation.