CodeIgniter Forums
Transaction not completed but trans_status NOT false - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 2.x (https://forum.codeigniter.com/forumdisplay.php?fid=18)
+--- Thread: Transaction not completed but trans_status NOT false (/showthread.php?tid=80007)



Transaction not completed but trans_status NOT false - _DoubleD_ - 09-01-2021

Hi there,
I'm currently facing a weird issue with an "old" CI (2.1.3).
Within the same method, I start a transaction, run some updates & inserts, commit the transaction and if everything is OK, I send an email.
It's been working for years, until today, without any code changes.
// Start the transaction
$this->db->trans_start();
                            

// Do my updates & inserts

// Complete the transaction
$this->db->trans_complete();

if ($this->db->trans_status() === FALSE) {

// Return an error
} else {
// Send an email
}
Today's event : The email has been sent but without any inserts & updates done. I could see the queries being run. So, I assume it has rollbacked.
Three questions : 
- Why can I have a trans_status to TRUE if it has rollbacked ? Am I missing something ?
- In Production, db_debug is at false, does it make any difference ? I was not able to see any logs, so I don't know where it has failed.
- How can I test a transaction failure ? I tried with using unknown table names. If db_debug is set to true, I get a 500. If db_debug is set to false, it goes all the way and returns a 200, BUT, the transaction is rollbacked and the trans_status is set to false. It works as expected


RE: Transaction not completed but trans_status NOT false - InsiteFX - 09-02-2021

I would check with your hosting provider and see if they have made any changes to the server

Like PHP, updated MySQL etc;


RE: Transaction not completed but trans_status NOT false - _DoubleD_ - 09-02-2021

(09-02-2021, 04:50 AM)InsiteFX Wrote: I would check with your hosting provider and see if they have made any changes to the server

Like PHP, updated MySQL etc;

I host the code on private servers and nothing has changed since a hosting change two years ago. But still, is there a case or a scenario that would lead to a rollback AND a status set to TRUE ?
I've a single and unique transaction. Maybe if the same request is called  simultaneously...I'm giving up Smile