mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Actually, all of parallel restore's limitations should be tested earlier.
On closer inspection, whining in restore_toc_entries_parallel is really much too late for any user-facing error case. The right place to do it is at the start of RestoreArchive(), before we've done anything interesting (suh as trying to DROP all the targets ...) Back-patch to 8.4, where parallel restore was introduced.
This commit is contained in:
		@@ -213,6 +213,7 @@ void
 | 
			
		||||
RestoreArchive(Archive *AHX, RestoreOptions *ropt)
 | 
			
		||||
{
 | 
			
		||||
	ArchiveHandle *AH = (ArchiveHandle *) AHX;
 | 
			
		||||
	bool		parallel_mode;
 | 
			
		||||
	TocEntry   *te;
 | 
			
		||||
	teReqs		reqs;
 | 
			
		||||
	OutputContext sav;
 | 
			
		||||
@@ -238,6 +239,27 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
 | 
			
		||||
	if (ropt->createDB && ropt->single_txn)
 | 
			
		||||
		die_horribly(AH, modulename, "-C and -1 are incompatible options\n");
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * If we're going to do parallel restore, there are some restrictions.
 | 
			
		||||
	 */
 | 
			
		||||
	parallel_mode = (ropt->number_of_jobs > 1 && ropt->useDB);
 | 
			
		||||
	if (parallel_mode)
 | 
			
		||||
	{
 | 
			
		||||
		/* We haven't got round to making this work for all archive formats */
 | 
			
		||||
		if (AH->ClonePtr == NULL || AH->ReopenPtr == NULL)
 | 
			
		||||
			die_horribly(AH, modulename, "parallel restore is not supported with this archive file format\n");
 | 
			
		||||
 | 
			
		||||
		/* Doesn't work if the archive represents dependencies as OIDs */
 | 
			
		||||
		if (AH->version < K_VERS_1_8)
 | 
			
		||||
			die_horribly(AH, modulename, "parallel restore is not supported with archives made by pre-8.0 pg_dump\n");
 | 
			
		||||
 | 
			
		||||
		/*
 | 
			
		||||
		 * It's also not gonna work if we can't reopen the input file, so
 | 
			
		||||
		 * let's try that immediately.
 | 
			
		||||
		 */
 | 
			
		||||
		(AH->ReopenPtr) (AH);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Make sure we won't need (de)compression we haven't got
 | 
			
		||||
	 */
 | 
			
		||||
@@ -385,7 +407,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
 | 
			
		||||
	 *
 | 
			
		||||
	 * In parallel mode, turn control over to the parallel-restore logic.
 | 
			
		||||
	 */
 | 
			
		||||
	if (ropt->number_of_jobs > 1 && ropt->useDB)
 | 
			
		||||
	if (parallel_mode)
 | 
			
		||||
		restore_toc_entries_parallel(AH);
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
@@ -3257,20 +3279,6 @@ restore_toc_entries_parallel(ArchiveHandle *AH)
 | 
			
		||||
 | 
			
		||||
	ahlog(AH, 2, "entering restore_toc_entries_parallel\n");
 | 
			
		||||
 | 
			
		||||
	/* we haven't got round to making this work for all archive formats */
 | 
			
		||||
	if (AH->ClonePtr == NULL || AH->ReopenPtr == NULL)
 | 
			
		||||
		die_horribly(AH, modulename, "parallel restore is not supported with this archive file format\n");
 | 
			
		||||
 | 
			
		||||
	/* doesn't work if the archive represents dependencies as OIDs, either */
 | 
			
		||||
	if (AH->version < K_VERS_1_8)
 | 
			
		||||
		die_horribly(AH, modulename, "parallel restore is not supported with archives made by pre-8.0 pg_dump\n");
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * It's also not gonna work if we can't reopen the input file, so let's
 | 
			
		||||
	 * try that immediately.
 | 
			
		||||
	 */
 | 
			
		||||
	(AH->ReopenPtr) (AH);
 | 
			
		||||
 | 
			
		||||
	slots = (ParallelSlot *) calloc(sizeof(ParallelSlot), n_slots);
 | 
			
		||||
 | 
			
		||||
	/* Adjust dependency information */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user