duckdb / duckdb_spatial

MIT License
489 stars 40 forks source link

Creating RTREE index twice causes duckdb to segfault #417

Closed CGenie closed 1 month ago

CGenie commented 1 month ago

This shouldn't happen I think (load some empty database with duckdb test.duckdb):

load spatial;
create table nodes (name varchar, pt geometry);
create index if not exists nodes_pt_idx on nodes using rtree(pt);
create index if not exists nodes_pt_idx on nodes using rtree(pt);

results in:

[1]    53183 segmentation fault (core dumped)  duckdb test.duckdb
CGenie commented 1 month ago

Moreover, the I can't seem to open that db:

Error: unable to open database "test.duckdb": INTERNAL Error: Failure while replaying WAL file "test.duckdb.wal": Index type "RTREE" not recognized
This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/dev/internal_errors
Maxxen commented 1 month ago

DuckDB doesnt know that the rtree index comes from the spatial extension and doesnt know how to reconstruct it during WAL replay, you need to first startup DuckDB, load spatial and then use the "attach" command to open the database, at which point DuckDB can continue replaying the WAL

CGenie commented 1 month ago

Yes, I understand. Still, it shouldn't segfault in the first place :)