X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 03E05474E44 for ; Tue, 4 Feb 2003 17:01:19 -0500 (EST) Received: from mail.intrusic.com (unknown [63.251.138.101]) by postgresql.org (Postfix) with ESMTP id 75AB8474E42 for ; Tue, 4 Feb 2003 17:01:18 -0500 (EST) Received: from cha1-mail1.intrusic.com (unknown [66.150.201.166]) by mail.intrusic.com (Postfix) with ESMTP id DC93CF07 for ; Tue, 4 Feb 2003 16:28:43 -0500 (EST) Received: from intrusic.com (timmah.charles.intrusic.com [192.168.100.69]) by cha1-mail1.intrusic.com (Postfix) with ESMTP id E7756C55A5 for ; Tue, 4 Feb 2003 17:01:00 -0500 (EST) Message-ID: <3E403A3E.5020508@intrusic.com> Date: Tue, 04 Feb 2003 17:10:06 -0500 From: justin Organization: Intrusic, Inc. User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.0) Gecko/20020729 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Serialized Transaction Locking Issues Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/82 X-Sequence-Number: 11480 Hello, I'm currently in the midst of working on a serializable transaction which drops indexes on several tables, does a bulk copy, and rebuilds the indexes. Based on what I've read it seemed as though I'd be able to concurrently execute read only queries against these tables, returning results based on the table snapshot from before the serialized transaction began. However, this doesn't work. A simple read-only select query waits until the serialized transaction is finished before returning results. Based on the user documentation, specifically (http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=explicit-locking.html#LOCKING-TABLES), it would seem that the only issue in PostgreSQL that could block a simple select call would be an ACCESS EXCLUSIVE lock, which is acquired only by DROP TABLE, ALTER TABLE, and VACUUM FULL, none of which I'm using. In fact, I've noticed this exact behavior with DROP INDEX. Please excuse my futile attempt to outline two concurrent transactions here: testdb=# \d trans_test Table "public.trans_test" Column | Type | Modifiers - -------+--------+----------- val integer Indexes: idx_trans_test btree(val) testdb=# SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE; SET [TRANSACTION 1] BEGIN; BEGIN [TRANSACTION 1] SELECT * FROM trans_test; val - ----- 1 2 [TRANSACTION 2] SELECT * FROM trans_test; val - ----- 1 2 [TRANSACTION 1] DROP INDEX idx_trans_test; DROP INDEX [TRANSACTION 2] SELECT * FROM trans_test; ... (Waiting) [TRANSACTION 1] COMMIT; COMMIT (TRANSACTION 2 returns after TRANSACTION 1 COMMIT) val - ----- 1 2 So is this a glitch or am I missing some nuance of a serializable transaction? In either case I'm eager to figure out whats actually going on. Thanks, -justin