[ 
https://issues.apache.org/jira/browse/HIVE-14774?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15512057#comment-15512057
 ] 

Chaoyu Tang commented on HIVE-14774:
------------------------------------

[~mohitsabharwal] SQLOperation is running a query in a background thread, its 
driver does lock acquisition, query execution etc. When Ctrl-C shuts down 
Beeline, it triggers TServerEventHandler deleteContext which in term closes the 
Session therefore cleaning up the operation (in the session thread). This 
cleanup close/destroy Driver (nullify its fields like ctx, plan etc), so the 
Driver running in background might fail in a certain step by RuntimeException 
(e.g. NPE) which have not been handled completely or properly in Hive. In a 
race condition when the Drive is about to acquire the locks in background 
thread and the SQLOperation cleanup has destroyed/closed driver but not yet 
kill the ground thread, the query process running in the background could still 
be able to acquire the locks but these locks might never have a chance to be 
cleared later.
The simplest and right way is first to kill the running query in the 
background, followed by driver close/destroy which ensures that  the locks, if 
any, acquired in the Driver would be cleared.
Does that make sense?


> Canceling query using Ctrl-C in beeline might lead to stale locks
> -----------------------------------------------------------------
>
>                 Key: HIVE-14774
>                 URL: https://issues.apache.org/jira/browse/HIVE-14774
>             Project: Hive
>          Issue Type: Bug
>          Components: Locking
>            Reporter: Chaoyu Tang
>            Assignee: Chaoyu Tang
>         Attachments: HIVE-14774.patch
>
>
> Terminating a running query using Ctrl-C in Beeline might lead to stale locks 
> since the process running the query might still be able to acquire the locks 
> but fail to release them after the query terminate abnormally.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to