Subject Re: [firebird-php] Re: Proper transaction & deadlock handling
Author Daniel Miller

I would love to be able to check error codes - my try/catch is actually supposed to do that (using errmsg instead of errcode).  But there's no error being returned by ibase_query.  A warning is thrown - and it doesn't even hit my try/catch block.  Do I need to instantiate a custom error handler?

Daniel

On 11/21/2016 2:03 AM, max@... [firebird-php] wrote:
Hi Daniel,

It's been a while since I coded a solution to this but as best I recall this is what I did in a similar situation.

I think I ended up checking the specific error code that is returned when you get a deadlock. For this I think you can use ibase_errorcode. You should be able to look up all the various error codes and what they mean for your version of Firebird. You can then test for the errror code and if matched retry your query.

It will obviously depend on your polling interval as to how may times you retry. You might also want to randomise a suitable delay between each retry.

One other thing that might help is that if you are trying to work on mulitple rows is to work in "chunks" rather than trying to do the whole lot in one go. In this way the chances of a deadlock between the two processes might be reduced, or you might end up with fewer "chunks" to reprocess on each retry if there is a deadlock.

Regards,

Max