pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Douglas McNaught <doug@mcnaught.org>
Cc: Surabhi Ahuja <surabhi.ahuja@iiitb.ac.in>
Cc: pgsql-general@postgresql.org
Subject: Re: transactions
Date: Mon, 6 Jun 2005 08:05:34 -0600
Message-ID: <20050606140534.GA38033@winnie.fuhr.org> (raw)
In-Reply-To: <m2vf4r39kk.fsf@Douglas-McNaughts-Powerbook.local>
References: <CE5C48E227F8ED4990FAC4332100ADC621B543@EVS.iiitb.ac.in>
	<m2vf4r39kk.fsf@Douglas-McNaughts-Powerbook.local>

On Mon, Jun 06, 2005 at 09:21:15AM -0400, Douglas McNaught wrote:
> "Surabhi Ahuja " <surabhi.ahuja@iiitb.ac.in> writes:
> 
> > say i have two transactions going on simultaneoulsy.
> > in one transaction i do an insertion
> > and the other transaction i do a delete.
> > what will happen if in both the transactions, the insert(in one) and
> > delete(in the other) are issued at exactly the same time? will bothe get
> > blocked and enter into a deadlock, if yes then do both the transactions
> > get aborted after some time of waiting.
> 
> The transactions will be executed completely independently, unless you
> do explicit locking (via SELECT FOR UPDATE or LOCK TABLE).

Deadlock can still happen if Transaction A's INSERT blocks because
of something Transaction B did previously, and Transaction B's
DELETE blocks because of something Transaction A did previously.
Foreign key relationships are a typical cause, but even UPDATEs on
simple tables can cause later operations to deadlock if the application
isn't careful with its order of operations.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



view thread (58+ messages)  latest in thread

Message-ID: <20050606140534.GA38033@winnie.fuhr.org>
Permalink:  ../20050606140534.GA38033@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20050606140534.GA38033@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: mike@fuhr.org, doug@mcnaught.org, surabhi.ahuja@iiitb.ac.in
  Subject: Re: transactions
  In-Reply-To: <20050606140534.GA38033@winnie.fuhr.org>
  References: <CE5C48E227F8ED4990FAC4332100ADC621B543@EVS.iiitb.ac.in> <m2vf4r39kk.fsf@Douglas-McNaughts-Powerbook.local> <20050606140534.GA38033@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox