commit errors

From: Ryan VanderBijl <rvbijl-pgsql(at)vanderbijlfamily(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: commit errors
Date: 2003-02-03 05:21:00
Message-ID: 20030203052100.GA2934@vanderbijlfamily.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

Within an application, if I receive an error executing 'BEGIN',
'ROLLBACK', or 'COMMIT', what should I do?

What is the "official" recommendation, if any?
What do you (anyone) do?

I'm especially interested in serializable transactions, if that
makes a difference.

Yes, the documentation says I should either get 'COMMIT' back,
or 'WARNING: COMMIT: no transaciton in progress'. However,
what if, for example, the tcp/ip connection drops at that
point? What should my application do?

Currently my code looks something like:

bool function_to_do_whatever() {
while(1) {
if (!begin_serializable_transaction()) {
log("aborting: begin transaction failure");
return false;
}

if (!execute( ... )) {
if (!rollback_transaction()) {
log("aborting: error rollback transaction");
return false;
}
log("retrying: error executing ...");
continue;
}

if (!commit_transaction()) {
log("aborting: commit transaction failure");
return false;
}
break;
}

log("database transaction commited.");
return true;
}

--
Ryan VanderBijl rvbijl(at)vanderbijlfamily(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-02-03 05:22:22 Re: Query plan question, and a memory leak
Previous Message Greg Stark 2003-02-03 04:38:43 Re: Query plan question, and a memory leak