By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,805 Members | 1,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,805 IT Pros & Developers. It's quick & easy.

how to retry a transaction in postgres

P: 1
I have a lua script that runs some commands against a sqlite database. IN sqlite, there's the concept of a busy timeout, where if a transaction fails because a lock cannot be obtained, it will wait x number of milliseconds and then try again.

I'm wondering how I can accomplish the same thing in postgresql? I did read some sql code where someone had a for loop... and it would just keep looping until all the results from the update statements were successful. but I'm using lua ... can someone give me a link with an example to follow or some basic pseudo code?
May 29 '13 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 700
You can use pg_advisory_lock()

set your own lock in the first transaction, and check if the lock is set in the second transaction.

See here for example
Jun 11 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.