9.6.3 - Backend Crash - Parallel Worker Prepared Statements

Jarred Ward <jarred@simple.com>

From: Jarred Ward <jarred@simple.com>
To: pgsql-bugs@postgresql.org
Date: 2017-08-08T21:56:53Z
Lists: pgsql-bugs
We are experiencing a crash with parallel worker processes enabled in
one of our production 9.6.3 databases on Linux. When parallel workers
are disable, the issue does not occur.

Here is a full repro of the issue on 9.6.3 (tested on macOS 10.12.5
below):

jward@slip:~ $ grep '^max_.*worker' /usr/local/var/postgres/postgresql.conf
max_worker_processes = 8
max_parallel_workers_per_gather = 8
jward@slip:~ $ createdb repro
jward@slip:~ $ psql repro
psql (9.6.3)
Type "help" for help.

repro=# create extension if not exists "uuid-ossp";
CREATE EXTENSION
repro=# create table foo (bar uuid primary key, baz uuid not null, qux uuid not null);
CREATE TABLE
repro=# insert into foo select uuid_generate_v4(), uuid_generate_v4(), uuid_generate_v4() from generate_series(1, 250000);
INSERT 0 250000
repro=# explain select * from foo where baz = uuid_generate_v4() or qux = uuid_generate_v4();
                                 QUERY PLAN                                 
----------------------------------------------------------------------------
 Gather  (cost=1000.00..6528.27 rows=2494 width=48)
   Workers Planned: 1
   ->  Parallel Seq Scan on foo  (cost=0.00..5278.87 rows=1467 width=48)
         Filter: ((baz = uuid_generate_v4()) OR (qux = uuid_generate_v4()))
(4 rows)

repro=# prepare test_select_jward (uuid, uuid) as select * from foo where baz = $1 or qux = $2;
PREPARE
repro=# execute test_select_jward ('1c5356b1-ba77-475e-9e16-60be44ab8f70', '0103d5e1-1ae1-3100-9fcd-8adc6f3e43d6');
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.
!> 

Please let me know if there is any further information I can provide.

Thank you,
Jarred Ward

Commits

  1. Fix datumSerialize infrastructure to not crash on non-varlena data.