• N
    Fix motion hazard between outer and joinqual · fa762b69
    Ning Yu 提交于
    A motion hazard is a deadlock between motions, a classic motion hazard
    in a join executor is formed by its inner and outer motions, it can be
    prevented by prefetching the inner plan, refer to motion_sanity_check()
    for details.
    
    A similar motion hazard can be formed by the outer motion and the join
    qual motion.  A join executor fetches a outer tuple, filters it with the
    join qual, then repeat the process on all the outer tuples.  When there
    are motions in both outer plan and the join qual then below state is
    possible:
    
    0. processes A and B belong to the join slice, process C belongs to the
       outer slice, process D belongs to the JoinQual slice;
    1. A has read the first outer tuple and is fetching tuples from D;
    2. D is waiting for ACK from B;
    3. B is fetching the first outer tuple from C;
    4. C is waiting for ACK from A;
    
    So a deadlock is formed A->D->B->C->A.  We can prevent it also by
    prefetching the join qual.
    Reviewed-by: NJesse Zhang <jzhang@pivotal.io>
    Reviewed-by: NGang Xiong <gxiong@pivotal.io>
    Reviewed-by: NZhenghua Lyu <zlv@pivotal.io>
    fa762b69
deadlock2.out 5.0 KB