Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 6CCF21337E24 for ; Tue, 29 Mar 2011 17:18:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 24003-03-7 for ; Tue, 29 Mar 2011 20:18:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from web33205.mail.mud.yahoo.com (web33205.mail.mud.yahoo.com [209.191.69.153]) by mail.postgresql.org (Postfix) with SMTP id 63C151337C1F for ; Tue, 29 Mar 2011 17:03:53 -0300 (ADT) Received: (qmail 99926 invoked by uid 60001); 29 Mar 2011 20:03:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1301429032; bh=auguhrQ9z+yvnmfpt5Zm81PyKn4OCi6P+TVDEF4CP9I=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=5j/lXpI7MW6Zwqu4xDeDhn2qOZr2OKzd05O4Fvz261ygZ4vlaz+Ia9c8k45FV6wwu9VIjkHTpcUR4liKF02yIx9B/WTdvegRP4mV+TpFdC8qFEYfc5Vamjr6Z1BWOnFDxrubp72bVE6baMcdPdgw8u9/gKO9gezsQ+gtqsHyi7I= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=IEXIFub+3k8WX42CMnxQgCDgRNmbukYpYslapqThoE3srePXR9WA3gy2gP8K+juXd4tNtmQqWH5gJtVzXvYYsK+g30bIt2dxegc6TX/MbJCPOV7L0QhFULTTJNVIxwNYyJQMfOarVMeIPOY6GBCa9EPoUyVkbeBnQ/Zt4FQ3SOI=; Message-ID: <421934.99909.qm@web33205.mail.mud.yahoo.com> X-YMail-OSG: I7QZnscVM1ltctPLn50Oiq0gYAw5m2WtMu6AROX61U2m4fH eYAt3EiffgS1zOC6wvDu.BP8zpUPzsIFp7uCb6pi7a6Cn0lGSWS3iWuHs5zO CDSdGMJs.JyilHX7R16YLUk.ptUBqBaZ_wj5tayD9HlGfv8CYJGKUvMaXEDP AN_ZKBxS8qtNzWbNmbv13uTt1GLvgcrTIIRyO7zA15ddMGvgGntY.wt.I7Kn FmrJVqhMXZdFqAR4a.Du_q7OMz7pDOvfnQfRHow1D8BfFj59e7sJK7hqD3.E suwXA_1oo4rVhrIaR_B.Zk6.QVrRso9MNDK92fX0UEEduLy6rjGDIdueLSEu p908xp2yZs1vFFvxIOwQ1FvG1mqaBLk91.HjHA.eEcfZNStwkjsx3BAI- Received: from [199.84.5.210] by web33205.mail.mud.yahoo.com via HTTP; Tue, 29 Mar 2011 13:03:51 PDT X-Mailer: YahooMailClassic/12.0.2 YahooMailWebService/0.8.109.295617 Date: Tue, 29 Mar 2011 13:03:51 -0700 (PDT) From: Quartz Subject: Re: JDBC gripe list To: pgsql-jdbc@postgresql.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, T_RP_MATCHES_RCVD=-0.01, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201103/112 X-Sequence-Number: 21667 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 wrote: > From: Quartz > 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... > >