mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Fix identify_locking_dependencies for schema-only dumps.
Without this fix, parallel restore of a schema-only dump can deadlock, because when the dump is schema-only, the dependency will still be pointing at the TABLE item rather than the TABLE DATA item. Robert Haas and Tom Lane
This commit is contained in:
		@@ -4153,11 +4153,14 @@ identify_locking_dependencies(TocEntry *te)
 | 
				
			|||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * We assume the item requires exclusive lock on each TABLE DATA item
 | 
						 * We assume the entry requires exclusive lock on each TABLE or TABLE DATA
 | 
				
			||||||
	 * listed among its dependencies.  (This was originally a dependency on
 | 
						 * item listed among its dependencies.  Originally all of these would have
 | 
				
			||||||
	 * the TABLE, but fix_dependencies repointed it to the data item. Note
 | 
						 * been TABLE items, but repoint_table_dependencies would have repointed
 | 
				
			||||||
	 * that all the entry types we are interested in here are POST_DATA, so
 | 
						 * them to the TABLE DATA items if those are present (which they might not
 | 
				
			||||||
	 * they will all have been changed this way.)
 | 
						 * be, eg in a schema-only dump).  Note that all of the entries we are
 | 
				
			||||||
 | 
						 * processing here are POST_DATA; otherwise there might be a significant
 | 
				
			||||||
 | 
						 * difference between a dependency on a table and a dependency on its
 | 
				
			||||||
 | 
						 * data, so that closer analysis would be needed here.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	lockids = (DumpId *) malloc(te->nDeps * sizeof(DumpId));
 | 
						lockids = (DumpId *) malloc(te->nDeps * sizeof(DumpId));
 | 
				
			||||||
	nlockids = 0;
 | 
						nlockids = 0;
 | 
				
			||||||
@@ -4166,7 +4169,8 @@ identify_locking_dependencies(TocEntry *te)
 | 
				
			|||||||
		DumpId		depid = te->dependencies[i];
 | 
							DumpId		depid = te->dependencies[i];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (depid <= maxDumpId && tocsByDumpId[depid - 1] &&
 | 
							if (depid <= maxDumpId && tocsByDumpId[depid - 1] &&
 | 
				
			||||||
			strcmp(tocsByDumpId[depid - 1]->desc, "TABLE DATA") == 0)
 | 
								((strcmp(tocsByDumpId[depid - 1]->desc, "TABLE DATA") == 0) ||
 | 
				
			||||||
 | 
								  strcmp(tocsByDumpId[depid - 1]->desc, "TABLE") == 0))
 | 
				
			||||||
			lockids[nlockids++] = depid;
 | 
								lockids[nlockids++] = depid;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user