[PostGIS] #5808: Weird constant ram increase using topology
PostGIS
trac at osgeo.org
Thu Nov 7 05:58:53 PST 2024
#5808: Weird constant ram increase using topology
-----------------------+---------------------------
Reporter: latot | Owner: strk
Type: defect | Status: new
Priority: medium | Milestone: PostGIS 3.5.1
Component: topology | Version: 3.5.x
Resolution: | Keywords:
-----------------------+---------------------------
Comment (by lnicola):
I found a minimization for this bug, or a related one:
{{{
begin;
select topology.TopoGeo_addLinestring('t5808', 'LINESTRING(1 0,0 -1,-1 0,0
1)', 0); select topology.TopoGeo_addLinestring('t5808', 'LINESTRING(2 0,0
-2,-2 0,0 2)', 0);
rollback;
}}}
I tried to trace the allocations and found some potential leaks at these
two places:
-
https://gitea.osgeo.org/gitea/postgis/postgis/src/tag/3.5.0/liblwgeom/topo/lwgeom_topo.c#L681
(didn't pay attention, but I don't know if it gets freed on the path at
https://gitea.osgeo.org/gitea/postgis/postgis/src/tag/3.5.0/liblwgeom/topo/lwgeom_topo.c#L715)
-
https://gitea.osgeo.org/gitea/postgis/postgis/src/tag/3.5.0/liblwgeom/topo/lwgeom_topo.c#L6996,
which potentially doesn't get freed at
https://gitea.osgeo.org/gitea/postgis/postgis/src/tag/3.5.0/liblwgeom/topo/lwgeom_topo.c#L7006
Full stack traces:
{{{
Breakpoint 1.1, operator new (sz=72) at
../../../../src/libstdc++-v3/libsupc++/new_op.cc:43
43 in ../../../../src/libstdc++-v3/libsupc++/new_op.cc
#0 0x00007f1832385a95 in
geos::geom::GeometryFactory::createLineString(std::unique_ptr<geos::geom::CoordinateSequence,
std::default_delete<geos::geom::CoordinateSequence> >&&) const () from
/lib/x86_64-linux-gnu/libgeos.so.3.13.0
#1 0x00007f1832c0c579 in GEOSGeom_createLineString_r () from /lib/x86_64
-linux-gnu/libgeos_c.so.1
#2 0x00007f1831cfffd8 in LWGEOM2GEOS (lwgeom=lwgeom at entry=0x5619b60f6568,
autofix=autofix at entry=0 '\000') at ../liblwgeom/lwgeom_geos.c:471
#3 0x00007f1831d02a6e in _lwt_CheckEdgeCrossing (topo=0x5619b5ed35b0,
start_node=642, end_node=643, geom=0x5619b60f6568, myself=0) at
../liblwgeom/topo/lwgeom_topo.c:618
#4 0x00007f1831d1bee5 in _lwt_AddEdge.constprop.0 (topo=0x5619b5ed35b0,
start_node=<optimized out>, end_node=643, geom=0x5619b60f6568, modFace=1,
skipChecks=0) at ../liblwgeom/topo/lwgeom_topo.c:2488
#5 0x00007f1831d1340f in _lwt_AddLineEdge
(topo=topo at entry=0x5619b5ed35b0, edge=0x5619b60f6568,
tol=tol at entry=3.6000000000000001e-15,
handleFaceSplit=handleFaceSplit at entry=1,
forward=forward at entry=0x7fff73ce1650)
at ../liblwgeom/topo/lwgeom_topo.c:6879
#6 0x00007f1831d13e1c in _lwt_AddLine (topo=<optimized out>,
line=<optimized out>, tol=3.6000000000000001e-15, nedges=0x7fff73ce176c,
handleFaceSplit=1) at ../liblwgeom/topo/lwgeom_topo.c:7265
#7 0x00007f1831cf7aaa in TopoGeo_AddLinestring (fcinfo=0x5619b6059540) at
/build/postgis-vUdkWY/postgis-3.5.0+dfsg/topology/postgis_topology.c:5141
#8 0x00005619a0ec3e41 in ExecMakeFunctionResultSet
(fcache=0x5619b60586c0, econtext=econtext at entry=0x5619b6057d28,
argContext=0x5619b5e5dbf0, isNull=0x5619b6058668,
isDone=isDone at entry=0x5619b60586b0)
at ./build/../src/backend/executor/execSRF.c:624
#9 0x00005619a0eea836 in ExecProjectSRF (node=node at entry=0x5619b6057c20,
continuing=continuing at entry=false) at
./build/../src/backend/executor/nodeProjectSet.c:182
#10 0x00005619a0eea8d5 in ExecProjectSet (pstate=0x5619b6057c20) at
./build/../src/backend/executor/nodeProjectSet.c:106
#11 0x00005619a0eba7dd in ExecProcNode (node=0x5619b6057c20) at
./build/../src/include/executor/executor.h:274
#12 ExecutePlan (estate=0x5619b6057a08, planstate=0x5619b6057c20,
use_parallel_mode=<optimized out>, operation=CMD_SELECT, sendTuples=true,
numberTuples=0, direction=<optimized out>, dest=0x5619b604e248,
execute_once=<optimized out>)
at ./build/../src/backend/executor/execMain.c:1648
#13 standard_ExecutorRun (queryDesc=0x5619b5d9cb78, direction=<optimized
out>, count=0, execute_once=<optimized out>) at
./build/../src/backend/executor/execMain.c:365
#14 0x00005619a10782ae in PortalRunSelect
(portal=portal at entry=0x5619b5dc5348, forward=forward at entry=true, count=0,
count at entry=9223372036854775807, dest=dest at entry=0x5619b604e248) at
./build/../src/backend/tcop/pquery.c:924
#15 0x00005619a10798a8 in PortalRun (portal=portal at entry=0x5619b5dc5348,
count=count at entry=9223372036854775807, isTopLevel=isTopLevel at entry=true,
run_once=run_once at entry=true, dest=dest at entry=0x5619b604e248,
altdest=altdest at entry=0x5619b604e248, qc=0x7fff73ce1bc0) at
./build/../src/backend/tcop/pquery.c:768
#16 0x00005619a1075a24 in exec_simple_query (query_string=0x5619b5d20208
"select topology.TopoGeo_addLinestring('t5808', 'LINESTRING(1 0,0 -1,-1
0,0 1)', 0);") at ./build/../src/backend/tcop/postgres.c:1278
#17 0x00005619a1077660 in PostgresMain (dbname=<optimized out>,
username=<optimized out>) at ./build/../src/backend/tcop/postgres.c:4767
#18 0x00005619a1071e03 in BackendMain (startup_data=<optimized out>,
startup_data_len=<optimized out>) at
./build/../src/backend/tcop/backend_startup.c:105
#19 0x00005619a0fdc50e in postmaster_child_launch
(child_type=child_type at entry=B_BACKEND,
startup_data=startup_data at entry=0x7fff73ce2050 "",
startup_data_len=startup_data_len at entry=4,
client_sock=client_sock at entry=0x7fff73ce2070)
at ./build/../src/backend/postmaster/launch_backend.c:277
#20 0x00005619a0fe0215 in BackendStartup (client_sock=0x7fff73ce2070) at
./build/../src/backend/postmaster/postmaster.c:3593
#21 ServerLoop () at ./build/../src/backend/postmaster/postmaster.c:1674
#22 0x00005619a0fe1f30 in PostmasterMain (argc=argc at entry=5,
argv=argv at entry=0x5619b5cdcaa0) at
./build/../src/backend/postmaster/postmaster.c:1372
#23 0x00005619a0cf83da in main (argc=5, argv=0x5619b5cdcaa0) at
./build/../src/backend/main/main.c:197
Breakpoint 1.1, operator new (sz=96) at
../../../../src/libstdc++-v3/libsupc++/new_op.cc:43
43 in ../../../../src/libstdc++-v3/libsupc++/new_op.cc
0x00007f1832379cb3 in
geos::geom::CoordinateSequence::CoordinateSequence(unsigned long, bool,
bool, bool) () from /lib/x86_64-linux-gnu/libgeos.so.3.13.0
#0 0x00007f1832379cb3 in
geos::geom::CoordinateSequence::CoordinateSequence(unsigned long, bool,
bool, bool) () from /lib/x86_64-linux-gnu/libgeos.so.3.13.0
#1 0x00007f1832c0b262 in GEOSCoordSeq_copyFromBuffer_r () from
/lib/x86_64-linux-gnu/libgeos_c.so.1
#2 0x00007f1831cfdbce in ptarray_to_GEOSCoordSeq (pa=0x5619b5d839a0,
fix_ring=fix_ring at entry=0 '\000') at ../liblwgeom/lwgeom_geos.c:302
#3 0x00007f1831cfffd0 in LWGEOM2GEOS (lwgeom=0x5619b5d838f0,
autofix=<optimized out>) at ../liblwgeom/lwgeom_geos.c:470
#4 0x00007f1831d13bb6 in _lwt_AddLine (topo=<optimized out>,
line=<optimized out>, tol=7.2000000000000002e-15, nedges=0x7fff73ce176c,
handleFaceSplit=1) at ../liblwgeom/topo/lwgeom_topo.c:6996
#5 0x00007f1831cf7aaa in TopoGeo_AddLinestring (fcinfo=0x5619b6059540) at
/build/postgis-vUdkWY/postgis-3.5.0+dfsg/topology/postgis_topology.c:5141
#6 0x00005619a0ec3e41 in ExecMakeFunctionResultSet
(fcache=0x5619b60586c0, econtext=econtext at entry=0x5619b6057d28,
argContext=0x5619b5e49090, isNull=0x5619b6058668,
isDone=isDone at entry=0x5619b60586b0)
at ./build/../src/backend/executor/execSRF.c:624
#7 0x00005619a0eea836 in ExecProjectSRF (node=node at entry=0x5619b6057c20,
continuing=continuing at entry=false) at
./build/../src/backend/executor/nodeProjectSet.c:182
#8 0x00005619a0eea8d5 in ExecProjectSet (pstate=0x5619b6057c20) at
./build/../src/backend/executor/nodeProjectSet.c:106
#9 0x00005619a0eba7dd in ExecProcNode (node=0x5619b6057c20) at
./build/../src/include/executor/executor.h:274
#10 ExecutePlan (estate=0x5619b6057a08, planstate=0x5619b6057c20,
use_parallel_mode=<optimized out>, operation=CMD_SELECT, sendTuples=true,
numberTuples=0, direction=<optimized out>, dest=0x5619b60979d8,
execute_once=<optimized out>)
at ./build/../src/backend/executor/execMain.c:1648
#11 standard_ExecutorRun (queryDesc=0x5619b5d9cb78, direction=<optimized
out>, count=0, execute_once=<optimized out>) at
./build/../src/backend/executor/execMain.c:365
#12 0x00005619a10782ae in PortalRunSelect
(portal=portal at entry=0x5619b5dc5348, forward=forward at entry=true, count=0,
count at entry=9223372036854775807, dest=dest at entry=0x5619b60979d8) at
./build/../src/backend/tcop/pquery.c:924
#13 0x00005619a10798a8 in PortalRun (portal=portal at entry=0x5619b5dc5348,
count=count at entry=9223372036854775807, isTopLevel=isTopLevel at entry=true,
run_once=run_once at entry=true, dest=dest at entry=0x5619b60979d8,
altdest=altdest at entry=0x5619b60979d8, qc=0x7fff73ce1bc0) at
./build/../src/backend/tcop/pquery.c:768
#14 0x00005619a1075a24 in exec_simple_query (query_string=0x5619b5d20208
"select topology.TopoGeo_addLinestring('t5808', 'LINESTRING(2 0,0 -2,-2
0,0 2)', 0);") at ./build/../src/backend/tcop/postgres.c:1278
#15 0x00005619a1077660 in PostgresMain (dbname=<optimized out>,
username=<optimized out>) at ./build/../src/backend/tcop/postgres.c:4767
#16 0x00005619a1071e03 in BackendMain (startup_data=<optimized out>,
startup_data_len=<optimized out>) at
./build/../src/backend/tcop/backend_startup.c:105
#17 0x00005619a0fdc50e in postmaster_child_launch
(child_type=child_type at entry=B_BACKEND,
startup_data=startup_data at entry=0x7fff73ce2050 "",
startup_data_len=startup_data_len at entry=4,
client_sock=client_sock at entry=0x7fff73ce2070)
at ./build/../src/backend/postmaster/launch_backend.c:277
#18 0x00005619a0fe0215 in BackendStartup (client_sock=0x7fff73ce2070) at
./build/../src/backend/postmaster/postmaster.c:3593
#19 ServerLoop () at ./build/../src/backend/postmaster/postmaster.c:1674
#20 0x00005619a0fe1f30 in PostmasterMain (argc=argc at entry=5,
argv=argv at entry=0x5619b5cdcaa0) at
./build/../src/backend/postmaster/postmaster.c:1372
#21 0x00005619a0cf83da in main (argc=5, argv=0x5619b5cdcaa0) at
./build/../src/backend/main/main.c:197
Breakpoint 1.1, operator new (sz=32) at
../../../../src/libstdc++-v3/libsupc++/new_op.cc:43
43 in ../../../../src/libstdc++-v3/libsupc++/new_op.cc
0x00007f1832c0b241 in GEOSCoordSeq_copyFromBuffer_r () from /lib/x86_64
-linux-gnu/libgeos_c.so.1
#0 0x00007f1832c0b241 in GEOSCoordSeq_copyFromBuffer_r () from
/lib/x86_64-linux-gnu/libgeos_c.so.1
#1 0x00007f1831cfdbce in ptarray_to_GEOSCoordSeq (pa=0x5619b5d9c7b0,
fix_ring=fix_ring at entry=0 '\000') at ../liblwgeom/lwgeom_geos.c:302
#2 0x00007f1831cfffd0 in LWGEOM2GEOS (lwgeom=lwgeom at entry=0x5619b60f6568,
autofix=autofix at entry=0 '\000') at ../liblwgeom/lwgeom_geos.c:470
#3 0x00007f1831d02a6e in _lwt_CheckEdgeCrossing (topo=0x5619b5ed35b0,
start_node=642, end_node=643, geom=0x5619b60f6568, myself=0) at
../liblwgeom/topo/lwgeom_topo.c:618
#4 0x00007f1831d1bee5 in _lwt_AddEdge.constprop.0 (topo=0x5619b5ed35b0,
start_node=<optimized out>, end_node=643, geom=0x5619b60f6568, modFace=1,
skipChecks=0) at ../liblwgeom/topo/lwgeom_topo.c:2488
#5 0x00007f1831d1340f in _lwt_AddLineEdge
(topo=topo at entry=0x5619b5ed35b0, edge=0x5619b60f6568,
tol=tol at entry=3.6000000000000001e-15,
handleFaceSplit=handleFaceSplit at entry=1,
forward=forward at entry=0x7fff73ce1650)
at ../liblwgeom/topo/lwgeom_topo.c:6879
#6 0x00007f1831d13e1c in _lwt_AddLine (topo=<optimized out>,
line=<optimized out>, tol=3.6000000000000001e-15, nedges=0x7fff73ce176c,
handleFaceSplit=1) at ../liblwgeom/topo/lwgeom_topo.c:7265
#7 0x00007f1831cf7aaa in TopoGeo_AddLinestring (fcinfo=0x5619b6059540) at
/build/postgis-vUdkWY/postgis-3.5.0+dfsg/topology/postgis_topology.c:5141
#8 0x00005619a0ec3e41 in ExecMakeFunctionResultSet
(fcache=0x5619b60586c0, econtext=econtext at entry=0x5619b6057d28,
argContext=0x5619b5e5dbf0, isNull=0x5619b6058668,
isDone=isDone at entry=0x5619b60586b0)
at ./build/../src/backend/executor/execSRF.c:624
#9 0x00005619a0eea836 in ExecProjectSRF (node=node at entry=0x5619b6057c20,
continuing=continuing at entry=false) at
./build/../src/backend/executor/nodeProjectSet.c:182
#10 0x00005619a0eea8d5 in ExecProjectSet (pstate=0x5619b6057c20) at
./build/../src/backend/executor/nodeProjectSet.c:106
#11 0x00005619a0eba7dd in ExecProcNode (node=0x5619b6057c20) at
./build/../src/include/executor/executor.h:274
#12 ExecutePlan (estate=0x5619b6057a08, planstate=0x5619b6057c20,
use_parallel_mode=<optimized out>, operation=CMD_SELECT, sendTuples=true,
numberTuples=0, direction=<optimized out>, dest=0x5619b604e248,
execute_once=<optimized out>)
at ./build/../src/backend/executor/execMain.c:1648
#13 standard_ExecutorRun (queryDesc=0x5619b5d9cb78, direction=<optimized
out>, count=0, execute_once=<optimized out>) at
./build/../src/backend/executor/execMain.c:365
#14 0x00005619a10782ae in PortalRunSelect
(portal=portal at entry=0x5619b5dc5348, forward=forward at entry=true, count=0,
count at entry=9223372036854775807, dest=dest at entry=0x5619b604e248) at
./build/../src/backend/tcop/pquery.c:924
#15 0x00005619a10798a8 in PortalRun (portal=portal at entry=0x5619b5dc5348,
count=count at entry=9223372036854775807, isTopLevel=isTopLevel at entry=true,
run_once=run_once at entry=true, dest=dest at entry=0x5619b604e248,
altdest=altdest at entry=0x5619b604e248, qc=0x7fff73ce1bc0) at
./build/../src/backend/tcop/pquery.c:768
#16 0x00005619a1075a24 in exec_simple_query (query_string=0x5619b5d20208
"select topology.TopoGeo_addLinestring('t5808', 'LINESTRING(1 0,0 -1,-1
0,0 1)', 0);") at ./build/../src/backend/tcop/postgres.c:1278
#17 0x00005619a1077660 in PostgresMain (dbname=<optimized out>,
username=<optimized out>) at ./build/../src/backend/tcop/postgres.c:4767
#18 0x00005619a1071e03 in BackendMain (startup_data=<optimized out>,
startup_data_len=<optimized out>) at
./build/../src/backend/tcop/backend_startup.c:105
#19 0x00005619a0fdc50e in postmaster_child_launch
(child_type=child_type at entry=B_BACKEND,
startup_data=startup_data at entry=0x7fff73ce2050 "",
startup_data_len=startup_data_len at entry=4,
client_sock=client_sock at entry=0x7fff73ce2070)
at ./build/../src/backend/postmaster/launch_backend.c:277
#20 0x00005619a0fe0215 in BackendStartup (client_sock=0x7fff73ce2070) at
./build/../src/backend/postmaster/postmaster.c:3593
#21 ServerLoop () at ./build/../src/backend/postmaster/postmaster.c:1674
#22 0x00005619a0fe1f30 in PostmasterMain (argc=argc at entry=5,
argv=argv at entry=0x5619b5cdcaa0) at
./build/../src/backend/postmaster/postmaster.c:1372
#23 0x00005619a0cf83da in main (argc=5, argv=0x5619b5cdcaa0) at
./build/../src/backend/main/main.c:197
}}}
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5808#comment:10>
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