BRIN index creation on geometry column causes crash

From: Tobias Wendorff <tobias(dot)wendorff(at)tu-dortmund(dot)de>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: BRIN index creation on geometry column causes crash
Date: 2025-01-02 22:02:27
Message-ID: fb6d9a35-6c8e-4869-af80-0a4944a793a4@tu-dortmund.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I'm reporting a server crash that occurs when creating a BRIN index on a
geometry column in PostgreSQL 17.2.

### Steps to reproduce
1. Set up PostgreSQL 17.2 with PostGIS 3.5.1 extension
2. Execute the following SQL commands:

```sql
DROP TABLE IF EXISTS random_points;
CREATE TABLE random_points AS
SELECT ST_MakePoint(0, 0) AS geom FROM generate_series(1, 130_561);
CREATE INDEX ON random_points USING brin(geom);
```

### Expected behavior
The BRIN index should be created successfully without server termination.

### Actual behavior
The server terminates abruptly during index creation with the following
error:
```
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
The connection to the server was lost. Attempting reset: Failed.
```

### SELECT version();
```
PostgreSQL 17.2 (Debian 17.2-1.pgdg120+1) on x86_64-pc-linux-gnu,
compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
```

### SELECT PostGIS_Full_Version();
```
POSTGIS="3.5.1 48ab069" [EXTENSION] PGSQL="170"
GEOS="3.11.1-CAPI-1.17.1" SFCGAL="SFCGAL 1.4.1, CGAL 5.5.1, BOOST
1.74.0" PROJ="9.1.1 NETWORK_ENABLED=OFF
URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj
DATABASE_PATH=/usr/share/proj/proj.db" (compiled against PROJ 9.1.1)
LIBXML="2.9.14" LIBJSON="0.16" LIBPROTOBUF="1.4.1" WAGYU="0.5.0
(Internal)" TOPOLOGY
```

### Trace
IRC user "GrayShade" was so nice to reproduce the problem and to create
a trace (see attachment). He also told me that this information might be
important:
```
fcinfo is {flinfo = 0x0, context = 0x0, resultinfo = 0x0, fncollation =
0, isnull = false, nargs = 2, args = 0x7ffeec862140}
```

### Additional notes
- The crash is consistently reproducible with the provided test case.
- 130_561 seems to be the sweet spot. Try with 1E6 or higher, not lower.
- Default PostgreSQL configuration settings are being used.
- The server log is not available in the current session due to the crash.

Please let me know if you need any additional information or server logs
to investigate this issue.

Attachment Content-Type Size
trace.txt text/plain 5.1 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2025-01-03 00:15:06 Re: BRIN index creation on geometry column causes crash
Previous Message Tom Lane 2025-01-02 16:04:23 Re: Incorrect sort result caused by ROLLUP and WHERE operation