postgrespro/pg_wait_sampling

queryid not cleared after error or cancellation

shinderuk opened this issue · 2 comments

Here is a demo using two session distinguished with indentation:

postgres=# select * from pg_wait_sampling_current where pid = 65593;
  pid  | event_type |   event    | queryid 
-------+------------+------------+---------
 65593 | Client     | ClientRead |       0
(1 row)

		postgres=# select 1/0;
		ERROR:  division by zero

postgres=# select * from pg_wait_sampling_current where pid = 65593;
  pid  | event_type |   event    |       queryid        
-------+------------+------------+----------------------
 65593 | Client     | ClientRead | -8981983488509566257
(1 row)

		postgres=# select 1;
		 ?column? 
		----------
		        1
		(1 row)

postgres=# select * from pg_wait_sampling_current where pid = 65593;
  pid  | event_type |   event    | queryid 
-------+------------+------------+---------
 65593 | Client     | ClientRead |       0
(1 row)

		postgres=# insert into t values (1);
		ERROR:  duplicate key value violates unique constraint "t_a_idx"
		DETAIL:  Key (a)=(1) already exists.

postgres=# select * from pg_wait_sampling_current where pid = 65593;
  pid  | event_type |   event    |       queryid       
-------+------------+------------+---------------------
 65593 | Client     | ClientRead | 1148676815787657868
(1 row)

		postgres=# select 1;
		 ?column? 
		----------
		        1
		(1 row)

postgres=# select * from pg_wait_sampling_current where pid = 65593;
  pid  | event_type |   event    | queryid 
-------+------------+------------+---------
 65593 | Client     | ClientRead |       0
(1 row)

		postgres=# select pg_sleep(5);
		^CCancel request sent
		ERROR:  canceling statement due to user request

postgres=# select * from pg_wait_sampling_current where pid = 65593;
  pid  | event_type |   event    |       queryid        
-------+------------+------------+----------------------
 65593 | Client     | ClientRead | -3337425560800118576
(1 row)

This issue have to be resolved after changes discussed in #43

Fixed in v1.1.6