Re: Connection gets into state where all queries fail

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Scott Ribe <scott_ribe(at)killerbytes(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Connection gets into state where all queries fail
Date: 2004-06-22 22:41:38
Message-ID: 20040622224134.GD27296@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jun 22, 2004 at 04:30:15PM -0600, Scott Ribe wrote:
> > All your queries will be ignored until you complete the transaction,
> > either with a commit or a rollback. I find the message very clear, how
> > do you think it could be reworded to be more clear?
>
> What's not clear is why I should be told this when the invalid query ended
> with a commit.

Hmm, it only happens when you send the whole lot in a single query
strings. That's not recommended IIRC.

> > In your program, yes. Although I find it interesting that your commit
> > is ignored after the error. Just send it as a seperate query.
>
> Yes, exactly. I've never seen a commit be ignored like this--believe me I've
> had other erroneous queries, and the connections never got borked like this.

Will, it's definitly repeatable:

$ perl -MPg -e '$db = Pg::connectdb("dbname=kleptog");
$db->exec("begin; select error; commit;");
$db->exec("select 1");
print $db->errorMessage;'
ERROR: current transaction is aborted, queries ignored until end of
transaction block

> I'll certainly add such code as a fail-safe, but I'd still like to
> understand more fully what has happened. Can I really be 100% sure this
> would keep the connection usable, given that the 1 commit already somehow
> failed to end the transaction block? I can certainly understand that a
> commit submitted by itself might be recognized where for some reason the
> original one was skipped over, but I'd still like to know more about what
> happened.

If you send each query in a seperate request, it'll work. I don't know
if the current behaviour is really a bug...

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2004-06-22 22:47:47 Planner choice & tuning
Previous Message Scott Ribe 2004-06-22 22:30:15 Re: Connection gets into state where all queries fail