Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d6e7abe

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 2c5d6f1 commit d6e7abe

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
@@ -3265,6 +3265,12 @@ restore_toc_entries_parallel(ArchiveHandle *AH)
32653265
if (AH->version < K_VERS_1_8)
32663266
die_horribly(AH, modulename, "parallel restore is not supported with archives made by pre-8.0 pg_dump\n");
32673267

3268+
/*
3269+
* It's also not gonna work if we can't reopen the input file, so let's
3270+
* try that immediately.
3271+
*/
3272+
(AH->ReopenPtr) (AH);
3273+
32683274
slots = (ParallelSlot *) calloc(sizeof(ParallelSlot), n_slots);
32693275

32703276
/* 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
@@ -735,10 +735,15 @@ _ReopenArchive(ArchiveHandle *AH)
735735

736736
if (AH->mode == archModeWrite)
737737
die_horribly(AH, modulename, "can only reopen input archives\n");
738+
739+
/*
740+
* These two cases are user-facing errors since they represent unsupported
741+
* (but not invalid) use-cases. Word the error messages appropriately.
742+
*/
738743
if (AH->fSpec == NULL || strcmp(AH->fSpec, "") == 0)
739-
die_horribly(AH, modulename, "cannot reopen stdin\n");
744+
die_horribly(AH, modulename, "parallel restore from stdin is not supported\n");
740745
if (!ctx->hasSeek)
741-
die_horribly(AH, modulename, "cannot reopen non-seekable file\n");
746+
die_horribly(AH, modulename, "parallel restore from non-seekable file is not supported\n");
742747

743748
errno = 0;
744749
tpos = ftello(AH->FH);

0 commit comments

Comments
 (0)