Locks are used to support concurrency when many programs want to access the same table at the same time. It protects data from being corrupted or invalidated when several users attempt to access the database while others write to it.
The following lock modes will be defined in Hive.
* Shared (S)
* Exclusive (X)
As the name suggests, multiple shared locks can be acquired at the same time, whereas X lock blocks all other locks.
You can query and see the locks in Hive.
hive> SHOW LOCKS;
hive> SHOW LOCKS <TABLE_NAME>;
hive> SHOW LOCKS <TABLE_NAME> EXTENDED;
hive> SHOW LOCKS <TABLE_NAME> PARTITION (<PARTITION_DESC>);
hive> SHOW LOCKS <TABLE_NAME> PARTITION (<PARTITION_DESC>) EXTENDED;
If you want to view the locks in MySQL, use the below commands.
mysql> USE metastore;
mysql> SELECT * FROM HIVE_LOCKS;
If there is any lock, you can simply delete it using-
DELETE FROM hive_locks WHERE hl_lock_ext_id = 1234567;
Hope you find this article informative.
Please subscribe for more interesting updates.