pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Quartz <quartz12h@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: JDBC gripe list
Date: Tue, 29 Mar 2011 13:03:51 -0700 (PDT)
Message-ID: <421934.99909.qm@web33205.mail.mud.yahoo.com> (raw)

And I would add, the batch is considered a single transaction even though autocommit is true, which causes deadlock when you set a batch of updates in an order that will cause a deadlock.

Example: make a batch of updates for pk ID=1 to 10 while you make a 2nd batch from id=10 to 1. To increase the chance of success with a deadlock, you can toss in a pg_sleep() call to slow things down.

You will see a deadlock even though you never intended to use a lock.
As you might guess, this break our application ported from mysql...

The workaround is very bad: either sorting updates batch by PK which is costly, and sometimes not possible unless you totally know the semantic of the sql you are attempting, or interlacing a hack "COMMIT" as a sql statement in the batch, which is not legal since there was no "BEGIN" (but triggers something in postgres).



--- On Tue, 3/29/11, Quartz <quartz12h@yahoo.com> wrote:

> From: Quartz <quartz12h@yahoo.com>
> Subject: Re: [JDBC] JDBC gripe list
> To: pgsql-jdbc@postgresql.org
> Received: Tuesday, March 29, 2011, 3:29 PM
> addBatch()/executeBatch() is broken
> under autocommit=true.
> 
> Every statement is clearly supposed to be independant.
> Example: 5 insert statements, let's say the 2th and the 4th
> are on duplicate of primary key. All 3 others should still
> be performed but they aren't.
> 
> This breaks our application. We migrated from mysql, and
> BOOM...
> 
> 



view thread (65+ messages)  latest in thread

Message-ID: <421934.99909.qm@web33205.mail.mud.yahoo.com>
Permalink:  ../421934.99909.qm@web33205.mail.mud.yahoo.com/
Also on:    postgresql.org/message-id/421934.99909.qm@web33205.mail.mud.yahoo.com

 · 

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-jdbc@postgresql.org
  Cc: quartz12h@yahoo.com
  Subject: Re: JDBC gripe list
  In-Reply-To: <421934.99909.qm@web33205.mail.mud.yahoo.com>
  References: <421934.99909.qm@web33205.mail.mud.yahoo.com>

* 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