Opened 9 years ago

Closed 9 years ago

#3479 closed defect (fixed)

ST_ClusterKMeans hangs with one row

Reported by: robe Owned by: pramsey
Priority: blocker Milestone: PostGIS 2.3.0
Component: postgis Version: master
Keywords: Cc:

Description (last modified by robe)

My postgres server just hangs. Simpler

DROP TABLE IF EXISTS parcels;
CREATE TABLE parcels AS 
SELECT 1 AS parcel_id, 
    ST_MakeEnvelope(0,0,200,200) As geom;


-- now try to do a ST_ClusterKMeans
SELECT ST_ClusterKMeans(geom,3) over () AS cid, geom
FROM parcels;


My server just hangs not sure what it's doing. I had to kill all my postgres processes.

Change History (11)

comment:1 by robe, 9 years ago

Description: modified (diff)
Summary: ST_ClusterKMeans hangsST_ClusterKMeans hangs with one row

comment:2 by pramsey, 9 years ago

Congratulations, it's replicable on OSX. Will get on it.

comment:3 by pramsey, 9 years ago

Should be better at r14719

comment:4 by robe, 9 years ago

Resolution: fixed
Status: newclosed

yah this just gives error now no crashing.

ERROR:  K (3) must be smaller than the number of rows in the group (1)

But you aren't done yet, see #3481 - monkey script smashed your function.

comment:5 by robe, 9 years ago

Resolution: fixed
Status: closedreopened

comment:6 by robe, 9 years ago

Okay it just crashes, does 1 work on your machine. Maybe now it's a windows issue.

POSTGIS="2.3.0dev r14719" GEOS="3.5.0-CAPI-1.9.0 r4090" SFCGAL="1.2.2" PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.0.1, released 2015/09/15" LIBXML="2.7.8" LIBJSON="0.12" RASTER PostgreSQL 9.5.1, compiled by Visual C++ build 1800, 64-bit
SELECT ST_ClusterKMeans(geom,1) over () AS cid, geom
FROM parcels;

crashes back end

This might be the same issue as #3481

comment:7 by pramsey, 9 years ago

No, the 1-entry case does not crash for me.

SELECT ST_ClusterKMeans(geom,1) over () AS cid, geom
 FROM parcels;

Didn't you report getting the error string earlier?

comment:8 by robe, 9 years ago

Yes when I do 3 for number of clusters. If I change it to 1 for number of clusters it crashes.

comment:9 by robe, 9 years ago

I was hoping I could give you a useful backtrace, but backtrace seems very uninformative.

Says no stack

and error just

[Thread 1460.0x17a8 exited with code 0]
[Thread 1460.0x480 exited with code 3]
[Thread 1460.0x17b0 exited with code 3]
[Inferior 1 (process 1460) exited with code 03]

comment:10 by pramsey, 9 years ago

Yeah, I cowboyed a change in after the initial fix and it broke the n=k case, sorry, should be fixed at r14733

comment:11 by pramsey, 9 years ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.