• Tom Lane's avatar
    Separate reinitialization of shared parallel-scan state from ExecReScan. · 41b0dd98
    Tom Lane authored
    Previously, the parallel executor logic did reinitialization of shared
    state within the ExecReScan code for parallel-aware scan nodes.  This is
    problematic, because it means that the ExecReScan call has to occur
    synchronously (ie, during the parent Gather node's ReScan call).  That is
    swimming very much against the tide so far as the ExecReScan machinery is
    concerned; the fact that it works at all today depends on a lot of fragile
    assumptions, such as that no plan node between Gather and a parallel-aware
    scan node is parameterized.  Another objection is that because ExecReScan
    might be called in workers as well as the leader, hacky extra tests are
    needed in some places to prevent unwanted shared-state resets.
    
    Hence, let's separate this code into two functions, a ReInitializeDSM
    call and the ReScan call proper.  ReInitializeDSM is called only in
    the leader and is guaranteed to run before we start new workers.
    ReScan is returned to its traditional function of resetting only local
    state, which means that ExecReScan's usual habits of delaying or
    eliminating child rescan calls are safe again.
    
    As with the preceding commit 7df2c1f8, it doesn't seem to be necessary
    to make these changes in 9.6, which is a good thing because the FDW and
    CustomScan APIs are impacted.
    
    Discussion: https://postgr.es/m/CAA4eK1JkByysFJNh9M349u_nNjqETuEnY_y1VUc_kJiU0bxtaQ@mail.gmail.com
    41b0dd98
custom-scan.sgml 15.6 KB