[postgis-tickets] [PostGIS] #5000: ST_AsMVT crash with OVER(ORDER BY random())

PostGIS trac at osgeo.org
Tue Oct 5 15:55:29 PDT 2021


#5000: ST_AsMVT crash with OVER(ORDER BY random())
----------------------+---------------------------
  Reporter:  robe     |      Owner:  pramsey
      Type:  defect   |     Status:  new
  Priority:  medium   |  Milestone:  PostGIS 3.0.5
 Component:  postgis  |    Version:  2.5.x
Resolution:           |   Keywords:
----------------------+---------------------------

Comment (by pramsey):

 Trying to take a few notes. I do not have it 100% pinned down, but it
 comes down to this:

 The code is written with an expectation of an aggregate function, which is
 that when the finalizefn is called you are DONE. But that expectation is
 actually WRONG. When called in a window context, a function is expected to
 finalize and emit its CURRENT STATE but remain available to keep adding to
 that state. So finalizefn can be called on a given context MULTIPLE TIMES.

 The MVT code currently takes a TupleDesc from PgSQL, which it needs to
 release to avoid leaking into the PgSQL cache. However, simply keeping
 that TupleDesc around does not seem sufficient to avoid the windowing
 problem, since we get a different crash if we just keep it around. So the
 finalize logic seems to depend to some degree on cleaning up the context.
 This is the unknown part of the problem.

 Unfortunately this is all made even more complex by the fact that the
 ST_AsMVT function is parallelizeable so it can convert a context into an
 intermediate serialization (an MVT, as it happens) which can then be
 combined before the final final finalization. So the lifecycle of this
 stuff is really complex.

-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5000#comment:3>
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