Opened 2 months ago

Closed 8 weeks ago

#5137 closed defect (fixed)

interrupt handler called in wrong query

Reported by: kalenik Owned by: pramsey
Priority: medium Milestone: PostGIS 3.2.2
Component: postgis Version: 3.2.x
Keywords: Cc:

Description

Example:

kalenik=# select st_npoints(st_buffer(st_makevalid(test.geom), 123, 'quad_segs=99999')) from test;
^CCancel request sent
ERROR:  canceling statement due to user request
kalenik=# select count(*) from test, st_subdivide(test.geom);
 count 
-------
     0
(1 row)

kalenik=# select count(*) from test, st_subdivide(test.geom);
 count 
-------
   119
(1 row)

in the example you may see that after first query was interrupt next query returns empty set although there are 119 after subdivision of geometry in the table which is becomes clear after repeat execution.

I did little investigation and found out that the reason is _lwgeom_interrupt_requested variable which indicates if interruption yet needs to be handled on lwgeom side. in the example this variable is set to 1 while first query execution and is not handled anywhere because interruption happened on GEOS side and query execution just ended. when the second query with ST_Subdivide starts executing variable _lwgeom_interrupt_requested is still set to 1 because no LW_ON_INTERRUPT which sets this variable back to 0 haven't been called yet. ST_Subdivide stumbles over not handled interruption because it has LW_ON_INTERRUPT check and returns empty set and sets _lwgeom_interrupt_requested to 0. Last query returns right result because there is no interrupt to be handled.

So the problem is that if some function got interrupted and this interrupt hasn't been handled by LW_ON_INTERRUPT it won't be handled until function that calls LW_ON_INTERRUPT is encountered which is clearly wrong.

Change History (1)

comment:1 by Regina Obe <lr@…>, 8 weeks ago

Resolution: fixed
Status: newclosed

In 0428945/git:

using ExecutorStart_hook to reset interrupt flags
Add to NEWS
Closes https://github.com/postgis/postgis/pull/685
Closes #5137

Note: See TracTickets for help on using tickets.