@@ -3218,12 +3218,12 @@ dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim)
3218
3218
* Main engine for parallel restore.
3219
3219
*
3220
3220
* Work is done in three phases.
3221
- * First we process tocEntries until we come to one that is marked
3222
- * SECTION_DATA or SECTION_POST_DATA, in a single connection, just as for a
3223
- * standard restore. Second we process the remaining non-ACL steps in
3224
- * parallel worker children (threads on Windows, processes on Unix), each of
3225
- * which connects separately to the database. Finally we process all the ACL
3226
- * entries in a single connection (that happens back in RestoreArchive).
3221
+ * First we process all SECTION_PRE_DATA tocEntries, in a single connection,
3222
+ * just as for a standard restore. Second we process the remaining non-ACL
3223
+ * steps in parallel worker children (threads on Windows, processes on Unix),
3224
+ * each of which connects separately to the database. Finally we process all
3225
+ * the ACL entries in a single connection (that happens back in
3226
+ * RestoreArchive).
3227
3227
*/
3228
3228
static void
3229
3229
restore_toc_entries_parallel (ArchiveHandle * AH )
@@ -3233,6 +3233,7 @@ restore_toc_entries_parallel(ArchiveHandle *AH)
3233
3233
ParallelSlot * slots ;
3234
3234
int work_status ;
3235
3235
int next_slot ;
3236
+ bool skipped_some ;
3236
3237
TocEntry pending_list ;
3237
3238
TocEntry ready_list ;
3238
3239
TocEntry * next_work_item ;
@@ -3262,12 +3263,31 @@ restore_toc_entries_parallel(ArchiveHandle *AH)
3262
3263
* showing all the dependencies of SECTION_PRE_DATA items, so we do not
3263
3264
* risk trying to process them out-of-order.
3264
3265
*/
3266
+ skipped_some = false;
3265
3267
for (next_work_item = AH -> toc -> next ; next_work_item != AH -> toc ; next_work_item = next_work_item -> next )
3266
3268
{
3267
- /* Non-PRE_DATA items are just ignored for now */
3268
- if (next_work_item -> section == SECTION_DATA ||
3269
- next_work_item -> section == SECTION_POST_DATA )
3270
- continue ;
3269
+ /* NB: process-or-continue logic must be the inverse of loop below */
3270
+ if (next_work_item -> section != SECTION_PRE_DATA )
3271
+ {
3272
+ /* DATA and POST_DATA items are just ignored for now */
3273
+ if (next_work_item -> section == SECTION_DATA ||
3274
+ next_work_item -> section == SECTION_POST_DATA )
3275
+ {
3276
+ skipped_some = true;
3277
+ continue ;
3278
+ }
3279
+ else
3280
+ {
3281
+ /*
3282
+ * SECTION_NONE items, such as comments, can be processed now
3283
+ * if we are still in the PRE_DATA part of the archive. Once
3284
+ * we've skipped any items, we have to consider whether the
3285
+ * comment's dependencies are satisfied, so skip it for now.
3286
+ */
3287
+ if (skipped_some )
3288
+ continue ;
3289
+ }
3290
+ }
3271
3291
3272
3292
ahlog (AH , 1 , "processing item %d %s %s\n" ,
3273
3293
next_work_item -> dumpId ,
@@ -3310,17 +3330,32 @@ restore_toc_entries_parallel(ArchiveHandle *AH)
3310
3330
*/
3311
3331
par_list_header_init (& pending_list );
3312
3332
par_list_header_init (& ready_list );
3333
+ skipped_some = false;
3313
3334
for (next_work_item = AH -> toc -> next ; next_work_item != AH -> toc ; next_work_item = next_work_item -> next )
3314
3335
{
3315
- /* All PRE_DATA items were dealt with above */
3336
+ /* NB: process-or-continue logic must be the inverse of loop above */
3337
+ if (next_work_item -> section == SECTION_PRE_DATA )
3338
+ {
3339
+ /* All PRE_DATA items were dealt with above */
3340
+ continue ;
3341
+ }
3316
3342
if (next_work_item -> section == SECTION_DATA ||
3317
3343
next_work_item -> section == SECTION_POST_DATA )
3318
3344
{
3319
- if (next_work_item -> depCount > 0 )
3320
- par_list_append (& pending_list , next_work_item );
3321
- else
3322
- par_list_append (& ready_list , next_work_item );
3345
+ /* set this flag at same point that previous loop did */
3346
+ skipped_some = true;
3323
3347
}
3348
+ else
3349
+ {
3350
+ /* SECTION_NONE items must be processed if previous loop didn't */
3351
+ if (!skipped_some )
3352
+ continue ;
3353
+ }
3354
+
3355
+ if (next_work_item -> depCount > 0 )
3356
+ par_list_append (& pending_list , next_work_item );
3357
+ else
3358
+ par_list_append (& ready_list , next_work_item );
3324
3359
}
3325
3360
3326
3361
/*
0 commit comments