473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to retry a transaction in postgres

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
1 2863
rski
700 Expert 512MB
You can use pg_advisory_lock()
http://www.postgresql.org/docs/curre...ADVISORY-LOCKS
http://www.postgresql.org/docs/curre...ADVISORY-LOCKS

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

See here for example
http://merlinmoncure.blogspot.co.uk/...tgresql-8.html
Jun 11 '13 #2

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

Similar topics

7
by: Abdul-Wahid Paterson | last post by:
Hi, I have had a site working for the last 2 years and have had no problems until at the weekend I replace my database server with a newer one. The database migration went like a dream and I had...
8
by: Alex | last post by:
Hi, I have a test system that is setup the same as a production system and would like to frequently copy the database over. pg_dump takes a few hours and even sometimes hangs. Are there any...
8
by: Barbara Lindsey | last post by:
Is there something in Postgres that corresponds to the rowid pseudocolumn in Oracle, which represents the unique address of the row of data in the table? If so, how would you access that in a...
12
by: John Sidney-Woollett | last post by:
I have to convert an java web application currently using an Oracle DB back end to one using a Postgres backend. In Oracle much of the application logic is abstracted away from the java...
15
by: Zeng | last post by:
Hi, The bigger my C# web-application gets, the more places I need to put in the tedious retrying block of code to make sure operations that can run into database deadlocks are re-run (retried)...
0
by: Paramveer.Singh | last post by:
Hi! I was looking into the postgres error handling mechanism, and the documentation states that the present mechanism is primitive. I quote "whenever the parser, planner/optimizer or executor...
8
by: Nick | last post by:
I have a table with columns (product_id,related_product_id,related_counter) If product A is related to product B then a record should be created, if the record already exists then the...
4
by: Shelly | last post by:
I am looking for some advice on the design of a transaction processing sequence. As I xcurrently have it, the sequence is as follows: 1 - Gather all the information from the user other than the...
1
by: micofarmer | last post by:
We are running a PHP web-based frontend with a Postgres 7.2 backend on a Windows 2000 Server box with automated backups of the server being handled by Legato. We are experiencing several problems...
1
by: ntech | last post by:
hello, i got a problem while restarting postgresql, i removed postmaste.pid and even the temporary sock file and while restarting postgres, i got the following error: LOG: could not bind IPv6...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.