X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx2.hub.org [200.46.204.254]) by postgresql.org (Postfix) with ESMTP id 1450011F6C85 for ; Wed, 12 Apr 2006 13:40:07 -0300 (ADT) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Score: -2.598 X-Spam-Level: X-Spam-Status: No, score=-2.598 required=5 tests=[BAYES_00=-2.599, UNPARSEABLE_RELAY=0.001] Received: from postgresql.org ([200.46.204.71]) by localhost (mx2.hub.org [200.46.204.254]) (amavisd-new, port 10024) with ESMTP id TAJzwqIHuxwp for ; Wed, 12 Apr 2006 13:40:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) by postgresql.org (Postfix) with ESMTP id BF1F011F68DF for ; Wed, 12 Apr 2006 13:40:01 -0300 (ADT) Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP with MS-WebStorage 6.0.6249 Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; 12 Apr 2006 09:38:13 -0700 Subject: Re: postgres jdbc transaction problem surfaces at times From: Mark Lewis To: kevin@mtel.co.uk Cc: pgsql-jdbc@postgresql.org In-Reply-To: <1144856469.014948.89160@j33g2000cwa.googlegroups.com> References: <1144856469.014948.89160@j33g2000cwa.googlegroups.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: MIR3, Inc. Date: Wed, 12 Apr 2006 09:38:12 -0700 Message-Id: <1144859893.5541.246.camel@archimedes> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-22) X-Archive-Number: 200604/93 X-Sequence-Number: 15027 This smells like a possible threading issue, where multiple threads are accessing the same connection object. Remember that the same HTTP session can be accessed by multiple threads concurrently, and the PostgreSQL JDBC driver is not thread-safe. To see if this is the case, try adding some additional synchronization to guarantee that no two threads will use the connection at the same time (perhaps by synchronizing on the Connection object). -- Mark On Wed, 2006-04-12 at 08:41 -0700, kevin@mtel.co.uk wrote: > i read in the posts here that postgres 8.0 jdbc had unmasked it;s > dislike of changing transaction level mid transaction so i changed my > code to the following > > is this set up correct? > > try { > livedb.setAutoCommit(false); > copydb.setAutoCommit(false); > > > livedb.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); > > copydb.setTransactionIsolation > (Connection.TRANSACTION_SERIALIZABLE); > > // series of writes to both db's > > livedb.commit(); > livedb.setAutoCommit(true); > copydb.commit(); > copydb.setAutoCommit(true); > > } catch (SQLException sqle){ > // run a rollback-Release and log it routine; > > // crash and burn; > } > > this seems to work fine single user, but with several users on i get > occasional dumps with > transaction change in transaction. > > the only code to change relates to the LUW start since the last rollout > of this servlet and there was never this problem before. > the connections are stored as a session attribute, so persist across > requests. > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq