Re: Re-run query on automatic reconnect - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Re-run query on automatic reconnect
Date
Msg-id 3248.1127768633@sss.pgh.pa.us
Whole thread Raw
In response to Re-run query on automatic reconnect  ("Jim C. Nasby" <jnasby@pervasive.com>)
List pgsql-hackers
"Jim C. Nasby" <jnasby@pervasive.com> writes:
> Is there any particular reason why psql doesn't re-run a query that
> failed due to disconnect from the server after re-connecting? I've
> thought maybe it's because it might somehow be dangerous, but I can't
> think of any case where that's actually true.

You haven't thought very hard.

(1) psql cannot tell whether the query was already completed before the
connection dropped; if so, reissuing it would make its effects if any
happen twice (eg, duplicate insert, or adding something to a bank
balance twice).

(2) If inside a transaction block, the query might or might not depend
on previous operations in the same transaction.

(3) The query might depend on previous session-local operations,
such as SET commands or creation of temp tables.

(4) If the query actually caused the server crash, re-issuing it will
probably cause another crash.  Instant infinite loop, complete with
denial of service to all other database users.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Open items list for 8.1
Next
From: "Dann Corbit"
Date:
Subject: Re: [PERFORM] A Better External Sort?