title: Hive Locks entire database when running select on one table
body: <p>HIVE 0.13 will SHARED lock the entire database(I see a node like LOCK-0000000000 as a child of the database node in Zookeeper) when running a select statement on any table in the database. HIVE creates a shared lock on the entire schema even when running a select statement - this results in a freeze on CREATE/DELETE statements on other tables in the database until the original query finishes and the lock is released.</p>
  
  <p>Does anybody know a way around this? Following link suggests concurrency to be turned off but we can't do that as we are replacing the entire table and we have to make sure that no select statement is accessing the table before we replace the entire contents.</p>
  
  <p><a href="http://mail-archives.apache.org/mod_mbox/hive-user/201408.mbox/%3C0eba01cfc035" rel="nofollow">http://mail-archives.apache.org/mod_mbox/hive-user/201408.mbox/%3C0eba01cfc035</a>$3501e4f0$9f05aed0$@com%3E</p>
  
  <pre><code>use mydatabase;
  select count(*) from large_table limit 1;     # this table is very large and hive.support.concurrency=true`
  </code></pre>
  
  <p>In another hive shell, meanwhile the 1st query is executing:</p>
  
  <pre><code>use mydatabase;
  create table sometable (id string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'  STORED AS TEXTFILE ;
  </code></pre>
  
  <p>The problem is that the “create table” does not execute untill the first query (select) has finished.</p>
  
  <p>Update:
  We are using Cloudera's distribution of Hive CDH-5.2.1-1 and we are seeing this issue. </p>