DaniWeb was written in Codeigniter, and when posting to the forums, we use database transactions that look like this:
$this->db->trans_start();
... insert into the posts table ...
... update the member's post count ...
... update the tags table ...
etc
$this->db->trans_complete();
On occassion, the error log will show for a particular query within the transaction: Query error: Deadlock found when trying to get lock; try restarting transaction - Invalid query
When that happens, the entire transaction is rolled back. However, this is not ideal because when someone attempts to make a post, we don't want it to completely fail just because the member's table happened to have been in use at the time.
That being said ... how do I go about restarting the transaction?? e.g. something such as:
if ($this->CI->db->trans_status() === false)
{
// Code to restart the transaction
}
Is there a better way to be doing it? Should I be manually locking tables?