Re: Disconnected but query still running - Mailing list pgsql-general

From Venkata Balaji N
Subject Re: Disconnected but query still running
Date
Msg-id CAEyp7J88WZ0dQR5WRSbYyDQK9EURg5KGzNY4Y7=7q2-ssNS0ow@mail.gmail.com
Whole thread Raw
In response to Disconnected but query still running  (Eduardo Piombino <drakorg@gmail.com>)
List pgsql-general
On Sat, Jul 11, 2015 at 8:53 AM, Eduardo Piombino <drakorg@gmail.com> wrote:

I've read that that a query still running after a disconnection is
normal, since the server won't realize about this disconnection until
it needs to send some data back to the client, which is ok and
understandable. But my question is, what happens when the query
finishes? FYI, the query was an update, in what would be autocommit
mode (no explicit transaction was open). Will the changes be commited?
or rollbacked because it will detect the disconnection later on?

If the autocommit is on and the transaction is not with-in BEING-END block, then, the changes should be committed. If the query/process detects the disconnection later on, it simply hangs which needs to be killed manually at the database end.
 
In
other words, is it worth waiting for this query to finish (it has been
running for almost 7 hours now), or should I cancel it because it will
irremediably be rolled back when the server finds theres no one on the
other end of the tcp connection?

Generally, when the application session is killed abnormally, the query still continues at the database end. If you want process not to continue anymore at the database-end, then, you need to manually kill it at the database end too using pg_cancel_backend() or pg_terminate_backend(). 

Regards,
Venkata Balaji N

Fujitsu Australia





pgsql-general by date:

Previous
From: Scott Whitney
Date:
Subject: Re: [ADMIN] could not create shared memory segment: Invalid argument
Next
From: Igor Stassiy
Date:
Subject: Creating table with data from a join