• Z
    Add Global Deadlock Detector. · 03915d65
    Zhenghua Lyu 提交于
    To prevent distributed deadlock, in Greenplum DB an exclusive table lock is
    held for UPDATE and DELETE commands, so concurrent updates the same table are
    actually disabled.
    
    We add a backend process to do global deadlock detect so that we do not lock
    the whole table while doing UPDATE/DELETE and this will help improve the
    concurrency of Greenplum DB.
    
    The core idea of the algorithm is to divide lock into two types:
    
    - Persistent: the lock can only be released after the transaction is over(abort/commit)
    - Otherwise cases
    
    This PR’s implementation adds a persistent flag in the LOCK, and the set rule is:
    
    - Xid lock is always persistent
    - Tuple lock is never persistent
    - Relation is persistent if it has been closed with NoLock parameter, otherwise
      it is not persistent Other types of locks are not persistent
    
    More details please refer the code and README.
    
    There are several known issues to pay attention to:
    
    - This PR’s implementation only cares about the locks can be shown
      in the view pg_locks.
    - This PR’s implementation does not support AO table. We keep upgrading
      the locks for AO table.
    - This PR’s implementation does not take networking wait into account.
      Thus we cannot detect the deadlock of GitHub issue #2837.
    - SELECT FOR UPDATE still lock the whole table.
    Co-authored-by: NZhenghua Lyu <zlv@pivotal.io>
    Co-authored-by: NNing Yu <nyu@pivotal.io>
    03915d65
select_for_update.sql 262 字节