Segmentation Fault during pg_restore using '--use-list' and '--jobs'

From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Segmentation Fault during pg_restore using '--use-list' and '--jobs'
Date: 2017-08-18 18:27:58
Message-ID: CAFcNs+pjuv0JL_x4+=71TPUPjdLHOXA4YfT32myj_OrrZb4ohA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

I'm facing a 'segmentation fault' error using '--use-list' and '--jobs'
options after update to 9.5.8.

We generate a list ignoring some 'TABLE DATA' toc for a selective restore.

See the test case below:

cat <<EOF | psql
\c postgres
drop database if exists test_restore;
create database test_restore;
\c test_restore

create table t1 (id serial primary key);
create table t2 (id serial primary key);
create table t3 (id serial primary key);
create table t4 (id serial primary key);
create table t5 (id serial primary key);

insert into t1 select * from generate_series(1,100);
insert into t2 select * from generate_series(1,100);
insert into t3 select * from generate_series(1,100);
insert into t4 select * from generate_series(1,100);
insert into t5 select * from generate_series(1,100);
EOF

-- generate complete dump file
pg_dump -Fc -v -f /tmp/test_restore.dump test_restore

-- generate a parcial list for selective restore ignoring some "TABLE DATA"
toc
pg_restore --list /tmp/test_restore.dump | grep -v -E 'TABLE DATA public
t(2|4)' > /tmp/test_restore.dump.list

-- rebuild database
cat <<EOF | psql
\c postgres
drop database if exists test_restore;
create database test_restore;
\c test_restore
EOF

-- try restore
pg_restore --jobs=2 --use-list=/tmp/test_restore.dump.list --format=custom
--dbname=test_restore --verbose /tmp/test_restore.dump

After execute pg_restore we got the following back trace (against master
branch):

#0 0x000000000041319b in par_list_append (l=0x0, te=0x9acf10) at
pg_backup_archiver.c:4129
#1 0x0000000000414539 in reduce_dependencies (AH=0x9a4480, te=0x9aa540,
ready_list=0x0) at pg_backup_archiver.c:4576
#2 0x00000000004128ec in restore_toc_entries_prefork (AH=0x9a4480,
pending_list=0x7ffffc0e3430) at pg_backup_archiver.c:3903
#3 0x0000000000406830 in RestoreArchive (AHX=0x9a4480) at
pg_backup_archiver.c:645
#4 0x0000000000404b82 in main (argc=7, argv=0x7ffffc0e3bb8) at
pg_restore.c:429

I've tested against REL9_5_STABLE and master and got the same error. Seems
the commit 65048cf23dbabf428897b5a74ad730e478dca5f3 added this regression.

In restore_toc_entries_prefork have a comment to don't touch 'read_list' so
pass NULL... but the reduce_dependencies doesn't check it. I'm really don't
know if it's correct but attached patch fix this issue.

Regards,

--
Fabrízio de Royes Mello Timbira - http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

Attachment Content-Type Size
segfault-pgrestore-using-list-and-parallel_v1.patch text/x-patch 580 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-08-18 18:45:28 Re: Update low-level backup documentation to match actual behavior
Previous Message Robert Haas 2017-08-18 17:31:44 Re: Hash Functions