lightning Posted June 14, 2007 Share Posted June 14, 2007 I created 2 sets of transactions in php with a sleep command in between. The sleep command is to simulate a transaction taking a long time. Transaction1 in 1 php page: BEGIN Query1 sleep(100) Query2 COMMIT; Transaction2 in another php page: BEGIN Query1 Query2 COMMIT; As soon as the Transaction 1 is executed from 1 php page, I tried to execute the Transaction2 php from another php page. Transaction 2 waited till Transaction 1 completed and then it executed. I want Transaction 2 to end after a few tries. It is because I have a cron job that might take about half an hour and therefore Transaction 2 should end after a few tries with some error messages. How is it done? Is it possible to set the number of tries or the waiting time through the Postgre SQL code? Quote Link to comment https://forums.phpfreaks.com/topic/55550-adjusting-the-waiting-time-in-transaction/ Share on other sites More sharing options...
btherl Posted June 28, 2007 Share Posted June 28, 2007 You can set statement_timeout to speed up failure: http://www.postgresql.org/docs/8.2/interactive/runtime-config-client.html#RUNTIME-CONFIG-CLIENT-STATEMENT Another option is to try to take an explicit lock on the resources your transaction needs with the nowait option: http://www.postgresql.org/docs/8.2/interactive/sql-lock.html Deadlock detection timeout is set here: http://www.postgresql.org/docs/8.2/interactive/runtime-config-locks.html But your situation is not a deadlock, so that will not affect you. I'm just pointing it out for completeness Quote Link to comment https://forums.phpfreaks.com/topic/55550-adjusting-the-waiting-time-in-transaction/#findComment-284509 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.