Opened 6 years ago

Closed 6 years ago

#4163 closed defect (fixed)

ST_AsMVT: Resource leak

Reported by: Algunenano Owned by: Algunenano
Priority: high Milestone: PostGIS 2.5.0
Component: postgis Version: 2.4.x
Keywords: Cc:

Description

Currently the resources generated during the aggregation process for St_AsMVT are freed in encode_values. The problem is that, in parallel plans, only one of the workers calls this function but all of them generate these intermediate resources.

This can be an issue as we cache not only memory (which should be freed at the end of the query) but Tuple Descriptors too, so Postgresql has to cleanup after as and throws warnings:

 2018-08-28 15:20:05.675 UTC [8063] WARNING: TupleDesc reference leak: TupleDesc 0x7fef02669288 (2249,0) still referenced
 2018-08-28 15:20:05.675 UTC [8063] WARNING: TupleDesc reference leak: TupleDesc 0x7fef02669288 (2249,0) still referenced

Affects 2.5 and trunk.

Change History (4)

comment:1 by Algunenano, 6 years ago

Summary: ST_AsMVT: Resource leak under parallel plansST_AsMVT: Resource leak

After investigating further I've discovered that this leak isn't caused by parallel plans, it just turned out to appear in the same tests where I get those plans.

The issue is in mvt_agg_transfn as it parses the columns if (layer->n_features == 0) which, in theory, should be only once. The problem comes when the first (or first N) row has a NULL geometry since that will go through the transformation without increasing layer->n_features.

In 2.4 this only meant unnecessary work, but in 2.5+ it means allocating memory again and leaking the resources from the previous call.

comment:2 by Raul Marin, 6 years ago

In 16708:

MVT: Fix resource leak when the first geometry is NULL

References #4163

comment:3 by Raul Marin, 6 years ago

In 16709:

MVT: Fix resource leak when the first geometry is NULL

References #4163

comment:4 by Raul Marin, 6 years ago

Resolution: fixed
Status: assignedclosed

In 16710:

MVT: Fix resource leak when the first geometry is NULL

Closes #4163

Note: See TracTickets for help on using tickets.