*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.169 2009/03/26 22:26:07 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.170 2009/04/12 21:02:44 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
static void mark_work_done(ArchiveHandle *AH, thandle worker, int status,
ParallelSlot *slots, int n_slots);
static void fix_dependencies(ArchiveHandle *AH);
+static bool has_lock_conflicts(TocEntry *te1, TocEntry *te2);
static void repoint_table_dependencies(ArchiveHandle *AH,
DumpId tableId, DumpId tableDataId);
static void identify_locking_dependencies(TocEntry *te,
return NO_SLOT;
}
+
+/*
+ * Check if te1 has an exclusive lock requirement for an item that te2 also
+ * requires, whether or not te2's requirement is for an exclusive lock.
+ */
+static bool
+has_lock_conflicts(TocEntry *te1, TocEntry *te2)
+{
+ int j,k;
+
+ for (j = 0; j < te1->nLockDeps; j++)
+ {
+ for (k = 0; k < te2->nDeps; k++)
+ {
+ if (te1->lockDeps[j] == te2->dependencies[k])
+ return true;
+ }
+ }
+ return false;
+}
+
+
+
/*
* Find the next work item (if any) that is capable of being run now.
*
bool pref_non_data = false; /* or get from AH->ropt */
TocEntry *data_te = NULL;
TocEntry *te;
- int i,j,k;
+ int i,k;
/*
* Bogus heuristics for pref_non_data
/*
* Check to see if the item would need exclusive lock on something
- * that a currently running item also needs lock on. If so, we
- * don't want to schedule them together.
+ * that a currently running item also needs lock on, or vice versa.
+ * If so, we don't want to schedule them together.
*/
for (i = 0; i < n_slots && !conflicts; i++)
{
if (slots[i].args == NULL)
continue;
running_te = slots[i].args->te;
- for (j = 0; j < te->nLockDeps && !conflicts; j++)
+
+ if (has_lock_conflicts(te, running_te) ||
+ has_lock_conflicts(running_te, te))
{
- for (k = 0; k < running_te->nLockDeps; k++)
- {
- if (te->lockDeps[j] == running_te->lockDeps[k])
- {
- conflicts = true;
- break;
- }
- }
+ conflicts = true;
+ break;
}
}