Re: Fix for parallel BTree initialization bug - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Fix for parallel BTree initialization bug
Date
Msg-id CAA4eK1+ss8TsnC7QwDPax_Fp+Wc24wrgCmCJ1T8-oxGw9car1w@mail.gmail.com
Whole thread Raw
In response to Fix for parallel BTree initialization bug  ("Jameson, Hunter 'James'" <hunjmes@amazon.com>)
List pgsql-hackers
On Tue, Sep 8, 2020 at 11:55 PM Jameson, Hunter 'James'
<hunjmes@amazon.com> wrote:
>
> Hi, I ran across a small (but annoying) bug in initializing parallel BTree scans, which causes the parallel-scan
statemachine to get confused. The fix is one line; the description is a bit longer— 
>
>
>
> Before, function _bt_first() would exit immediately if the specified scan keys could never be satisfied--without
notifyingother parallel workers, if any, that the scan key was done. 
>

The first question that comes to mind is how is it possible that for
one of the workers specified scan keys is not satisfied while for
others it is satisfied? I think it is possible when other workers are
still working on the previous scan key and this worker has moved to
the next scan key. If not, then what is the other case?

> This moved that particular worker to a scan key beyond what was in the shared parallel-query state, so that it would
latertry to read in "InvalidBlockNumber", without recognizing it as a special sentinel value. 
>

Now, if it happens as I mentioned then the other workers should not
try to advance their scan because their local scan key will be lesser
than shared key. Basically, they should return from the below
condition:
_bt_parallel_seize()
{
..
if (so->arrayKeyCount < btscan->btps_arrayKeyCount)
{
/* Parallel scan has already advanced to a new set of scankeys. */
status = false;
}
..
}

After this, those workers will also update their scan key and move
forward from there. So, I am not seeing how this could create a
problem.

--
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: torikoshia
Date:
Subject: Re: Get memory contexts of an arbitrary backend process
Next
From: Ranier Vilela
Date:
Subject: Re: Windows regress fails (latest HEAD)