Re: failed commit question

Lists: pgsql-novice
From: yamt(at)mwd(dot)biglobe(dot)ne(dot)jp (YAMAMOTO Takashi)
To: pgsql-novice(at)postgresql(dot)org
Subject: failed commit question
Date: 2011-02-10 08:52:10
Message-ID: 20110210085210.AE29119CE74@mail.netbsd.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

hi,

when COMMIT failed, does it leave the transaction opened
(thus ROLLBACK is necessary) ?

YAMAMOTO Takashi


From: Chetan Suttraway <chetan(dot)suttraway(at)enterprisedb(dot)com>
To: YAMAMOTO Takashi <yamt(at)mwd(dot)biglobe(dot)ne(dot)jp>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: failed commit question
Date: 2011-02-17 10:08:47
Message-ID: AANLkTimZh8sO+eb37suLd5BWZPhMy2MdiTwB2Nwtj5wF@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

On Thu, Feb 10, 2011 at 2:22 PM, YAMAMOTO Takashi <yamt(at)mwd(dot)biglobe(dot)ne(dot)jp>wrote:

> hi,
>
> when COMMIT failed, does it leave the transaction opened
> (thus ROLLBACK is necessary) ?
>

The transaction is marked for rollback.

check this discussion:
http://archives.postgresql.org/pgsql-jdbc/2005-01/msg00117.php

Tip: always try to dig up the archives for similar issues, before posting.

--
Chetan Sutrave
http://www.enterprisedb.com


From: yamt(at)mwd(dot)biglobe(dot)ne(dot)jp (YAMAMOTO Takashi)
To: chetan(dot)suttraway(at)enterprisedb(dot)com
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: failed commit question
Date: 2011-02-18 01:53:06
Message-ID: 20110218015306.48F8619CE65@mail.netbsd.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-novice

hi,

> On Thu, Feb 10, 2011 at 2:22 PM, YAMAMOTO Takashi <yamt(at)mwd(dot)biglobe(dot)ne(dot)jp>wrote:
>
>> hi,
>>
>> when COMMIT failed, does it leave the transaction opened
>> (thus ROLLBACK is necessary) ?
>>
>
> The transaction is marked for rollback.
>
> check this discussion:
> http://archives.postgresql.org/pgsql-jdbc/2005-01/msg00117.php

thanks.

it seems that the discussion is about a COMMIT after a failure of other
preceding commands in the transaction, right? i'm not sure as i'm not
familiar with java or jdbc.

my question was about a failed COMMIT. sorry if it was unclear.
for example, when a COMMIT failed due to a serialization error.
after posting the previous mail, i realized the way to trigger the
case and actually tried it. it seems that it terminates the transaction
even on the error. thus no need to rollback.

so i have a new question; is it safe to assume that it's same for any other
possible errors or should i consult PQtransactionStatus?

hoge=# commit;
ERROR: could not serialize access due to read/write dependencies among transactions
DETAIL: Cancelled on identification as a pivot, during commit attempt.
HINT: The transaction might succeed if retried.
hoge=# rollback;
NOTICE: there is no transaction in progress
ROLLBACK
hoge=#

>
> Tip: always try to dig up the archives for similar issues, before posting.

i asked google before posting, but failed to find an answer.
anyway, thanks for the tip.

YAMAMOTO Takashi

>
>
>
> --
> Chetan Sutrave
> http://www.enterprisedb.com