pg_wait_sampling icon indicating copy to clipboard operation
pg_wait_sampling copied to clipboard

queryid not cleared after error or cancellation

Open shinderuk opened this issue 3 years ago • 1 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)

shinderuk avatar Apr 08 '22 08:04 shinderuk

This issue have to be resolved after changes discussed in https://github.com/postgrespro/pg_wait_sampling/issues/43

maksm90 avatar Aug 15 '22 15:08 maksm90