From: | Reinoud van Leeuwen <reinoud(dot)v(at)n(dot)leeuwen(dot)net> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: [ADMIN] Deadlock on transaction |
Date: | 2007-02-12 18:59:19 |
Message-ID: | 20070212185919.GG677@spoetnik.xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-sql |
On Mon, Feb 12, 2007 at 03:08:27PM -0300, Ezequias Rodrigues da Rocha wrote:
> I mean really deadlock. Other transactions can't access the database until
> the main transaction is complete.
What you describe sounds like a blocking lock: one transaction uses a
resource and another has to wait until it is not locked anymore
A deadlock is a special case: two transactions both need resources A and
B. transaction 1 locks A, and the next moment transaction 2 locks B. Now
transaction 1 waits for 2 to release B, but at the same time 2 waits for 1
to release A. This is called a deadlock, or circulair lock.
Postgresql automatically detects such a situation and rolls one of them
back. The client recieves a 'restartable database error' and that is
exactly true: ususally another try will work.
One method of fixing deadlocks is to make sure all your code accesses the
database in the same order. Alphabetically is easiest to remember...
--
__________________________________________________
"Nothing is as subjective as reality"
Reinoud van Leeuwen reinoud(dot)v(at)n(dot)leeuwen(dot)net
http://www.xs4all.nl/~reinoud
__________________________________________________
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Kovacs | 2007-02-12 19:02:22 | pid file problem |
Previous Message | Richard Huxton | 2007-02-12 18:57:40 | Re: [SQL] Deadlock on transaction |
From | Date | Subject | |
---|---|---|---|
Next Message | Ezequias Rodrigues da Rocha | 2007-02-12 19:20:30 | Re: [SQL] Deadlock on transaction |
Previous Message | Richard Huxton | 2007-02-12 18:57:40 | Re: [SQL] Deadlock on transaction |