[postgis-tickets] [PostGIS] #5137: interrupt handler called in wrong query

PostGIS trac at osgeo.org
Tue Apr 19 16:02:56 PDT 2022


#5137: interrupt handler called in wrong query
---------------------+---------------------------
 Reporter:  kalenik  |      Owner:  pramsey
     Type:  defect   |     Status:  new
 Priority:  medium   |  Milestone:  PostGIS 3.2.2
Component:  postgis  |    Version:  3.2.x
 Keywords:           |
---------------------+---------------------------
 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.

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5137>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list