Skip to content

Commit fbf776a

Browse files
committed
Be more user-friendly about unsupported cases for parallel pg_restore.
If we are unable to do a parallel restore because the input file is stdin or is otherwise unseekable, we should complain and fail immediately, not after having done some of the restore. Complaining once per thread isn't so cool either, and the messages should be worded to make it clear this is an unsupported case not some weird race-condition bug. Per complaint from Lonni Friedman. Back-patch to 8.4, where parallel restore was introduced.
1 parent 42de04f commit fbf776a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3200,6 +3200,12 @@ restore_toc_entries_parallel(ArchiveHandle *AH)
32003200
if (AH->version < K_VERS_1_8)
32013201
die_horribly(AH, modulename, "parallel restore is not supported with archives made by pre-8.0 pg_dump\n");
32023202

3203+
/*
3204+
* It's also not gonna work if we can't reopen the input file, so let's
3205+
* try that immediately.
3206+
*/
3207+
(AH->ReopenPtr) (AH);
3208+
32033209
slots = (ParallelSlot *) calloc(sizeof(ParallelSlot), n_slots);
32043210

32053211
/* Adjust dependency information */

src/bin/pg_dump/pg_backup_custom.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,15 @@ _ReopenArchive(ArchiveHandle *AH)
866866

867867
if (AH->mode == archModeWrite)
868868
die_horribly(AH, modulename, "can only reopen input archives\n");
869+
870+
/*
871+
* These two cases are user-facing errors since they represent unsupported
872+
* (but not invalid) use-cases. Word the error messages appropriately.
873+
*/
869874
if (AH->fSpec == NULL || strcmp(AH->fSpec, "") == 0)
870-
die_horribly(AH, modulename, "cannot reopen stdin\n");
875+
die_horribly(AH, modulename, "parallel restore from stdin is not supported\n");
871876
if (!ctx->hasSeek)
872-
die_horribly(AH, modulename, "cannot reopen non-seekable file\n");
877+
die_horribly(AH, modulename, "parallel restore from non-seekable file is not supported\n");
873878

874879
errno = 0;
875880
tpos = ftello(AH->FH);

0 commit comments

Comments
 (0)