X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B8B97D1BA99 for ; Thu, 4 Sep 2003 14:06:14 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 36721-09 for ; Thu, 4 Sep 2003 11:06:07 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id CAE17D1BA68 for ; Thu, 4 Sep 2003 11:06:03 -0300 (ADT) 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 h84E67jX022650; Thu, 4 Sep 2003 10:06:07 -0400 (EDT) To: "David F. Skoll" Cc: pgsql-admin@postgresql.org Subject: Re: Row locking during UPDATE In-reply-to: References: Comments: In-reply-to "David F. Skoll" message dated "Thu, 04 Sep 2003 08:21:17 -0400" Date: Thu, 04 Sep 2003 10:06:07 -0400 Message-ID: <22649.1062684367@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/55 X-Sequence-Number: 10143 "David F. Skoll" writes: > What appears to be happening is this: > 1) Sometimes, a whole bunch of clients try updating the same row. I > see sevaral postgresql processes marked "UPDATE waiting" Any process that arrives at the row and finds it already modified by some concurrent transaction will wait for that concurrent transaction to complete. > 2) Because the client processes must complete rather quickly, a supervisor > process kills them if they don't complete soon. Zapping clients that are in the middle of database operations is bad design IMHO. > 3) The postgresql processes in an "UPDATE waiting" state seem to be > blocked waiting for a semaphore, and they do not notice the closing of > the connection when the client is killed. That's correct, a backend will generally not notice client disconnect until it next waits for a client command. It's not totally clear why you've got so many processes waiting to update the same row, though. Which process does have the row lock, and why isn't it completing its transaction? regards, tom lane