Managing Apache Hive
Also available as:
PDF

View transaction locks

As a Hive administrator, you can get troubleshooting information about locks on a table, partition, or schema.

Hive transactions, enabled by default, disables Zookeeper locking. DbLockManager stores and manages all transaction lock information in the Hive Metastore. Heartbeats are sent regularly from lock holders and transaction initiators to the Hive metastore to prevent stale locks and transactions. The lock or transaction is aborted if the metastore does not receive a heartbeat within the amount of time specified by the hive.txn.timeout configuration property.
You ensured that transactions are enabled (the default).
  1. Enter a Hive query to check table locks.
    SHOW LOCKS mytable EXTENDED;
                
  2. Check partition locks.
    SHOW LOCKS mytable PARTITION(ds='2018-05-01', hr='12') EXTENDED;
  3. Check schema locks.
    SHOW LOCKS SCHEMA mydatabase;
    The following information appears in the output unless ZooKeeper or in-memory lock managers are used.
    • Database name
    • Table name
    • Partition, if the table is partitioned
    • Lock state:
      • Acquired - transaction initiator hold the lock
      • Waiting - transaction initiator is waiting for the lock
      • Aborted - the lock has timed out but has not yet been cleaned
    • Lock type:
      • Exclusive - the lock cannot be shared
      • Shared_read - the lock cannot be shared with any number of other shared_read locks
      • Shared_write - the lock may be shared by any number of other shared_read locks but not with other shared_write locks
    • Transaction ID associated with the lock, if one exists
    • Last time lock holder sent a heartbeat
    • Time the lock was acquired, if it has been acquired
    • Hive user who requested the lock
    • Host machine on which the Hive user is running a Hive client
    • Blocked By ID - ID of the lock causing current lock to be in Waiting mode, if the lock is in this mode