• A
    Lock child partition tables at INSERT InitPlan() on QD · c7fce844
    Alexandra Wang 提交于
    INSERT needs to Lock the child table on QD, otherwise the following
    dead lock scenario may happen if INSERT runs concurrently with VACUUM
    drop phase on an AppendOnly partitioned table.
    
    1. VACUUM on QD: acquired AccessExclusiveLock on the child table
    2. INSERT on QE: acquired RowExclusiveLock on the child table
    3. VACUUM on QE: waiting for AccessExclusiveLock on the child table
    4. INSERT on QD: waiting for AccessShareLock at ExecutorEnd() on the
      child table, this is after QE sends back which child it inserted
    
    Note that in step 2, INSERT only locks the child table on QE, it does
    not lock the child table on QD in the previous code. This patch adds the
    lock on QD as well to prevent the above dead lock.
    
    Added `insert_while_vacuum_drop` and updated `partition_locking` to
    reflect the changes
    c7fce844
vacuum.c 97.7 KB