]> granicus.if.org Git - postgresql/commitdiff
Fix parallel index scan hang with deleted or half-dead pages.
authorRobert Haas <rhaas@postgresql.org>
Wed, 13 Dec 2017 21:09:00 +0000 (16:09 -0500)
committerRobert Haas <rhaas@postgresql.org>
Wed, 13 Dec 2017 21:15:44 +0000 (16:15 -0500)
The previous coding forgot to release the scan before seizing
it again, leading to a lockup.

Report by Patrick Hemmer.  Diagnosis by Thomas Munro.  Patch by
Amit Kapila.

Discussion: http://postgr.es/m/CAEepm=2xZUcOGP9V0O_G0=2P2wwXwPrkF=upWTCJSisUxMnuSg@mail.gmail.com

src/backend/access/nbtree/nbtsearch.c

index 558113bd13a859411f3d81824153ff0dd2b20238..12d3f081b6181aed3bf71b80f26a32df0ed30d69 100644 (file)
@@ -1486,6 +1486,11 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir)
                                if (_bt_readpage(scan, dir, P_FIRSTDATAKEY(opaque)))
                                        break;
                        }
+                       else if (scan->parallel_scan != NULL)
+                       {
+                               /* allow next page be processed by parallel worker */
+                               _bt_parallel_release(scan, opaque->btpo_next);
+                       }
 
                        /* nope, keep going */
                        if (scan->parallel_scan != NULL)
@@ -1581,6 +1586,11 @@ _bt_readnextpage(IndexScanDesc scan, BlockNumber blkno, ScanDirection dir)
                                if (_bt_readpage(scan, dir, PageGetMaxOffsetNumber(page)))
                                        break;
                        }
+                       else if (scan->parallel_scan != NULL)
+                       {
+                               /* allow next page be processed by parallel worker */
+                               _bt_parallel_release(scan, BufferGetBlockNumber(so->currPos.buf));
+                       }
 
                        /*
                         * For parallel scans, get the last page scanned as it is quite