BUG #14641: Segfault on searching KNN using btree_gist

From: darthunix(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14641: Segfault on searching KNN using btree_gist
Date: 2017-05-04 07:20:34
Message-ID: 20170504072034.24366.57688@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14641
Logged by: Denis Smirnov
Email address: darthunix(at)gmail(dot)com
PostgreSQL version: 9.6.2
Operating system: Ubuntu 14.04.5 LTS, Trusty Tahr x86_64
Description:

Hi,

I face a segmentation fault in postgresql when searching KNN using
multicolumn btree_gist index. The problem was reproduced on three equivalent
ubuntu servers. The problem is reproducing only with btree_gist index (if I
drop it, everything is ok)
Steps to reproduce:

create table t (id serial, amount money);

insert into t (amount) select (random() * 1000)::integer from
generate_series(1, 1000);

create extension btree_gist;

create index t_gist_idx on t using gist(id, amount);

select p.id, p.amount, s.nearest from t as p
left join lateral
(
select p.id, array_agg(l.id) as nearest from (
select id from t where amount < p.amount
order by amount <-> p.amount limit 10
) l
) s
using(id)
where p.id <= 500;
---------------------------------------------------------
WARNING: 57P02: terminating connection because of crash of another server
process
ПОДРОБНОСТИ: The postmaster has commanded this server process to roll back
the current transaction and exit, because another server process exited
abnormally and possibly corrupted shared memory.
ПОДСКАЗКА: In a moment you should be able to reconnect to the database and
repeat your command.
ПОЛОЖЕНИЕ: quickdie, postgres.c:2601
ошибка SSL SYSCALL: конец файла (EOF)
Подключение к серверу потеряно. Попытка восстановления удачна.

On some sandbox servers I got reproducing with p.id <= 15 on some only <=
500. PostgreSQL log:

2017-05-04 06:33:13 UTC [3682-24] DETAIL: Failed process was running:
select p.id, p.amount, s.nearest from t as p
left join lateral
(
select p.id, array_agg(l.id) as nearest from (
select id from t where amount < p.amount
order by amount <-> p.amount limit 10
) l
) s
using(id)
where p.id <= 500;
2017-05-04 06:33:13 UTC [3682-25] LOG: terminating any other active server
processes
2017-05-04 06:33:13 UTC [32302-2] WARNING: terminating connection because
of crash of another server process
2017-05-04 06:33:13 UTC [32302-3] DETAIL: The postmaster has commanded this
server process to roll back the current transaction and exit, because
another server process exited abnormally and possibly corrupted shared
memory.
2017-05-04 06:33:13 UTC [32302-4] HINT: In a moment you should be able to
reconnect to the database and repeat your command.
2017-05-04 06:33:13 UTC [3682-26] LOG: all server processes terminated;
reinitializing
2017-05-04 06:33:13 UTC [32309-1] LOG: database system was interrupted;
last known up at 2017-05-04 06:32:48 UTC
2017-05-04 06:33:13 UTC [32309-2] LOG: database system was not properly
shut down; automatic recovery in progress
2017-05-04 06:33:13 UTC [32309-3] LOG: invalid record length at 5/8E02F678:
wanted 24, got 0
2017-05-04 06:33:13 UTC [32309-4] LOG: redo is not required
2017-05-04 06:33:14 UTC [32309-5] LOG: MultiXact member wraparound
protections are now enabled
2017-05-04 06:33:14 UTC [3682-27] LOG: database system is ready to accept
connections
2017-05-04 06:33:14 UTC [32314-1] LOG: autovacuum launcher started

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message bashtanov 2017-05-04 12:29:23 BUG #14642: Excessive sorting node appears in the plan
Previous Message Peter Eisentraut 2017-05-04 03:29:29 Re: [BUGS] Concurrent ALTER SEQUENCE RESTART Regression