From shobha@phildigital.com Tue Apr 8 06:05:28 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 2318F4758C9 for ; Tue, 8 Apr 2003 02:05:28 -0400 (EDT) Received: from goatelecom.com (unknown [61.1.72.28]) by postgresql.org (Postfix) with ESMTP id F390F474E42 for ; Tue, 8 Apr 2003 02:05:22 -0400 (EDT) Received: from email.philnet (dialup-70-28.goatelecom.com [61.1.70.28]) by goatelecom.com (8.11.0/8.11.0) with ESMTP id h386KED25977 for ; Tue, 8 Apr 2003 11:50:15 +0530 (IST) Received: from phil.com.sg (IDENT:FrEvKjoPZgdkHq/Ad/0VqxB3mw5sjOvu@email.philnet [172.16.1.5]) by email.philnet (8.11.6/8.11.2) with ESMTP id h3863wv22089 for ; Tue, 8 Apr 2003 11:34:01 +0530 Message-ID: <3E92664D.313C3DFE@phil.com.sg> Date: Tue, 08 Apr 2003 11:33:58 +0530 From: SHOBHA HALDONKAR Reply-To: shobha@phildigital.com X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.17 i686) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: deadlock detection Content-Type: multipart/alternative; boundary="------------94F58B34003FAA992BD99F95" X-Spam-Status: No, hits=-3.6 required=5.0 tests=BAYES_10,HTML_10_20,RCVD_IN_RFCI version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/109 X-Sequence-Number: 8264 --------------94F58B34003FAA992BD99F95 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit HI , We are currenlty using postgresql 7.2.1 database. But it does not seem to detect deadlocks . Suppose if a record is locked with update command and another concurrent user tries to lock the same record and the first transaction for some reason , eg. m/c hangings is not committed both the transactions remains locked for indefinite period . I have checked the setting in postgresql.config for deadlock_timeout which is set to 1000 . Than why doesn't the transaction deatect deadlock after 1000 millisecond . Secondly if the frontend process is killed but due to some reason the backend postgres process remains , than how can it be terminated .For if i try to use kill command all the postgres processes gets terminated . Please help -- Regards, Shobha --------------94F58B34003FAA992BD99F95 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit  
HI ,

      We are currenlty using postgresql 7.2.1  database. But it does not seem to detect deadlocks .
       Suppose if a record is locked with update  command   and another concurrent user  tries to lock the same record and the first transaction for some reason , eg. m/c hangings   is not committed  both the transactions remains locked for indefinite period . I have checked the setting in postgresql.config  for deadlock_timeout  which is set to 1000 . Than why doesn't  the transaction deatect deadlock after 1000 millisecond  .
 Secondly if the frontend process  is killed but due to some reason the backend postgres process remains , than how can it be terminated .For
 if i try to use kill command all the postgres processes  gets terminated .
Please help

-- 
Regards,
Shobha
  --------------94F58B34003FAA992BD99F95-- From tgl@sss.pgh.pa.us Wed Apr 9 04:05:05 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 35C474758E6 for ; Wed, 9 Apr 2003 00:05:05 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 6AF0B474E42 for ; Wed, 9 Apr 2003 00:05:04 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h394532L004164; Wed, 9 Apr 2003 00:05:03 -0400 (EDT) To: shobha@phildigital.com Cc: pgsql-admin@postgresql.org Subject: Re: deadlock detection In-reply-to: <3E92664D.313C3DFE@phil.com.sg> References: <3E92664D.313C3DFE@phil.com.sg> Comments: In-reply-to SHOBHA HALDONKAR message dated "Tue, 08 Apr 2003 11:33:58 +0530" Date: Wed, 09 Apr 2003 00:05:03 -0400 Message-ID: <4163.1049861103@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-31.7 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/127 X-Sequence-Number: 8282 SHOBHA HALDONKAR writes: > Suppose if a record is locked with update command and another > concurrent user tries to lock the same record and the first transaction > for some reason , eg. m/c hangings is not committed both the > transactions remains locked for indefinite period . I have checked the > setting in postgresql.config for deadlock_timeout which is set to 1000 > . Than why doesn't the transaction deatect deadlock after 1000 > millisecond . Waiting for a client that chooses not to commit is not a deadlock. regards, tom lane From andrew.biagioni@e-greek.net Fri Apr 18 18:33:25 2003 X-Original-To: pgsql-admin@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9524B475E91 for ; Fri, 18 Apr 2003 14:33:25 -0400 (EDT) Received: from proteus.affordablehost.com (unknown [216.46.203.177]) by postgresql.org (Postfix) with SMTP id 6C9AB475458 for ; Fri, 18 Apr 2003 14:33:21 -0400 (EDT) Received: (qmail 8005 invoked from network); 18 Apr 2003 18:33:20 -0000 Received: from unknown (HELO e-greek.net) (66.92.74.181) by 216.46.203.177 with SMTP; 18 Apr 2003 18:33:20 -0000 Message-ID: <3EA044F3.2040303@e-greek.net> Date: Fri, 18 Apr 2003 14:33:23 -0400 From: Andrew Biagioni User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: shobha@phildigital.com, pgsql-admin@postgresql.org Subject: Re: deadlock detection References: <3E92664D.313C3DFE@phil.com.sg> <4163.1049861103@sss.pgh.pa.us> In-Reply-To: <4163.1049861103@sss.pgh.pa.us> Content-Type: multipart/alternative; boundary="------------000006060108040300020505" X-Spam-Status: No, hits=-37.0 required=5.0 tests=BAYES_10,EMAIL_ATTRIBUTION,HTML_10_20,IN_REP_TO, QUOTED_EMAIL_TEXT,REFERENCES,REPLY_WITH_QUOTES, USER_AGENT_MOZILLA_UA autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/258 X-Sequence-Number: 8413 This is a multi-part message in MIME format. --------------000006060108040300020505 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Tom Lane wrote: >SHOBHA HALDONKAR writes: > > >> Suppose if a record is locked with update command and another >>concurrent user tries to lock the same record and the first transaction >>for some reason , eg. m/c hangings is not committed both the >>transactions remains locked for indefinite period . I have checked the >>setting in postgresql.config for deadlock_timeout which is set to 1000 >>. Than why doesn't the transaction deatect deadlock after 1000 >>millisecond . >> >> > >Waiting for a client that chooses not to commit is not a deadlock. > > regards, tom lane > I used to be unclear on some of this, so I think I understand your confusion. This is how it works: The database assumes that you know what you are doing; if a transaction is not committed or rolled back, the lock remains (in 7.3 you can have transactions time out as well). If a connection drops, and you CANNOT terminate the transaction, the DB terminates it for you (ROLLBACK). Anywhere you have to wait for user interaction to complete an operation, AND you did a write before you started waiting for the user, you need ot find a way to break up the operation into two transactions, otherwise you WILL lock the DB (if the user goes to the restroom, or to lunch, or their keyboard breaks, ...). My approach is usually to store in the front end or middle layer anything I need to write, and actually write to the DB after the user interaction is complete (with no delays between start and end of transaction). Another approach is to set up the DB so that you can do your writes in multiple transactions without compromising data validity, although some times you need to run a clean-up every now and then to purge those operations that never completed. Beyond that... Get creative ! :-) Andrew --------------000006060108040300020505 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit

Tom Lane wrote:
SHOBHA HALDONKAR <shobha@phildigital.com> writes:
  
       Suppose if a record is locked with update  command   and another
concurrent user  tries to lock the same record and the first transaction
for some reason , eg. m/c hangings   is not committed  both the
transactions remains locked for indefinite period . I have checked the
setting in postgresql.config  for deadlock_timeout  which is set to 1000
. Than why doesn't  the transaction deatect deadlock after 1000
millisecond  .
    

Waiting for a client that chooses not to commit is not a deadlock.

			regards, tom lane

I used to be unclear on some of this, so I think I understand your confusion.  This is how it works:

The database assumes that you know what you are doing;  if a transaction is not committed or rolled back, the lock remains (in 7.3 you can have transactions time out as well).

If a connection drops, and you CANNOT terminate the transaction, the DB terminates it for you (ROLLBACK).

Anywhere you have to wait for user interaction to complete an operation, AND you did a write before you started waiting for the user, you need ot find a way to break up the operation into two transactions, otherwise you WILL lock the DB (if the user goes to the restroom, or to lunch, or their keyboard breaks, ...).

My approach is usually to store in the front end or middle layer anything I need to write, and actually write to the DB after the user interaction is complete (with no delays between start and end of transaction). 

Another approach is to set up the DB so that you can do your writes in multiple transactions without compromising data validity, although some times you need to run a clean-up every now and then to purge those operations that never completed.

Beyond that...  Get creative !  :-)

    Andrew

--------------000006060108040300020505--