Re: Disconnected but query still running

From: Venkata Balaji N <nag1010(at)gmail(dot)com>
To: Eduardo Piombino <drakorg(at)gmail(dot)com>
Cc: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Disconnected but query still running
Date: 2015-07-14 01:06:26
Message-ID: CAEyp7J88WZ0dQR5WRSbYyDQK9EURg5KGzNY4Y7=7q2-ssNS0ow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Jul 11, 2015 at 8:53 AM, Eduardo Piombino <drakorg(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Scott Ribe 2015-07-14 01:15:12 Re: could not create shared memory segment: Invalid argument
Previous Message Ryan King - NOAA Affiliate 2015-07-14 00:49:59 Re: could not create shared memory segment: Invalid argument