Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitece4bd9

Browse files
committed
Fix possible core dump in parallel restore when using a TOC list.
Commit3eb9a5e unintentionally introduced an ordering dependencyinto restore_toc_entries_prefork(). The existing coding ofreduce_dependencies() contains a check to skip moving a TOC entryto the ready_list if it wasn't initially in the pending_list.This used to suffice to prevent reduce_dependencies() from trying tomove anything into the ready_list during restore_toc_entries_prefork(),because the pending_list stayed empty throughout that phase; but it nolonger does. The problem doesn't manifest unless the TOC has beenreordered by SortTocFromFile, which is how I missed it in testing.To fix, just add a test for ready_list == NULL, converting the callwith NULL from a poor man's sanity check into an explicit commandnot to touch TOC items' list membership. Clarify some of the commentsaround this; in particular, note the primary purpose of the check forpending_list membership, which is to ensure that we can't try to restorethe same item twice, in case a TOC list forces it to be restored beforeits dependency count goes to zero.Per report from Fabrízio de Royes Mello. Back-patch to 9.3, like theprevious commit.Discussion:https://postgr.es/m/CAFcNs+pjuv0JL_x4+=71TPUPjdLHOXA4YfT32myj_OrrZb4ohA@mail.gmail.com
1 parentbc44044 commitece4bd9

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,8 +3536,9 @@ restore_toc_entries_prefork(ArchiveHandle *AH, TocEntry *pending_list)
35363536
*
35373537
* Note: as of 9.2, it should be guaranteed that all PRE_DATA items appear
35383538
* before DATA items, and all DATA items before POST_DATA items. That is
3539-
* not certain to be true in older archives, though, so this loop is coded
3540-
* to not assume it.
3539+
* not certain to be true in older archives, though, and in any case use
3540+
* of a list file would destroy that ordering (cf. SortTocFromFile). So
3541+
* this loop cannot assume that it holds.
35413542
*/
35423543
AH->restorePass=RESTORE_PASS_MAIN;
35433544
skipped_some= false;
@@ -3584,7 +3585,7 @@ restore_toc_entries_prefork(ArchiveHandle *AH, TocEntry *pending_list)
35843585

35853586
(void)restore_toc_entry(AH,next_work_item,ropt, false);
35863587

3587-
/*there should be no touch of ready_list here, so pass NULL */
3588+
/*Reduce dependencies, but don't move anything to ready_list */
35883589
reduce_dependencies(AH,next_work_item,NULL);
35893590
}
35903591
else
@@ -4262,7 +4263,7 @@ identify_locking_dependencies(ArchiveHandle *AH, TocEntry *te)
42624263
/*
42634264
* Remove the specified TOC entry from the depCounts of items that depend on
42644265
* it, thereby possibly making them ready-to-run. Any pending item that
4265-
* becomes ready should be moved to theready list.
4266+
* becomes ready should be moved to theready_list, if that's provided.
42664267
*/
42674268
staticvoid
42684269
reduce_dependencies(ArchiveHandle*AH,TocEntry*te,TocEntry*ready_list)
@@ -4279,15 +4280,19 @@ reduce_dependencies(ArchiveHandle *AH, TocEntry *te, TocEntry *ready_list)
42794280
otherte->depCount--;
42804281

42814282
/*
4282-
* It's ready if it has no remaining dependencies and it belongs in
4283-
* the current restore pass. However, don't move it if it has not yet
4284-
* been put into the pending list.
4283+
* It's ready if it has no remaining dependencies, and it belongs in
4284+
* the current restore pass, and it is currently a member of the
4285+
* pending list (that check is needed to prevent double restore in
4286+
* some cases where a list-file forces out-of-order restoring).
4287+
* However, if ready_list == NULL then caller doesn't want any list
4288+
* memberships changed.
42854289
*/
42864290
if (otherte->depCount==0&&
42874291
_tocEntryRestorePass(otherte)==AH->restorePass&&
4288-
otherte->par_prev!=NULL)
4292+
otherte->par_prev!=NULL&&
4293+
ready_list!=NULL)
42894294
{
4290-
/*It must be in thepending list, so remove it ... */
4295+
/*Remove it frompending list ... */
42914296
par_list_remove(otherte);
42924297
/* ... and add to ready_list */
42934298
par_list_append(ready_list,otherte);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp