Re: Command line session and running queries - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Command line session and running queries
Date
Msg-id fa7b473e0e4106f32f2193bb9ade569928f4d0a9.camel@cybertec.at
Whole thread Raw
In response to Command line session and running queries  (imp3 <impwins@yahoo.it>)
List pgsql-general
imp3 wrote:
> I've run an update query inside command line tool (psql) then I've exit the tool (closing the window).
> 
> When I re-logged in, I've noticed in pg_stat_activity that my query was still running.
> I used the command pg_cancel_backend with the right PID, but it returned "f" few seconds later.
> I re-checked pg_stat_activity and I was not able to see my query; there was only an autovacuum running on the table
impactedby my query.
 
> Since my update query usually takes about one hour, I was wandering what happened.
> 
> Is postgres regularly checking command line session? If session has expired, would postgres stop the query and
rollbackit?
 
> 
> I'm using both client and server v10.1.

The query probably endet by itself between the point in time when you saw
it in pg_stat_activity and when you tried to cancel it.

The PostgreSQL backend will only notice that the client has died when it
is done processing the query and tries to send an answer to the client.

If that is a regular problem for you, you could set "statement_timeout"
to put an upper limit on "runaway" queries.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com



pgsql-general by date:

Previous
From: naveen12
Date:
Subject: Re: pg_sample
Next
From: Dean Armada
Date:
Subject: MultiXactId 24018 has not been created yet -- apparent wraparound error