[ https://issues.apache.org/jira/browse/HIVE-20682?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16663616#comment-16663616 ]
Hive QA commented on HIVE-20682: -------------------------------- | (x) *{color:red}-1 overall{color}* | \\ \\ || Vote || Subsystem || Runtime || Comment || || || || || {color:brown} Prechecks {color} || | {color:green}+1{color} | {color:green} @author {color} | {color:green} 0m 0s{color} | {color:green} The patch does not contain any @author tags. {color} | || || || || {color:brown} master Compile Tests {color} || | {color:blue}0{color} | {color:blue} mvndep {color} | {color:blue} 0m 19s{color} | {color:blue} Maven dependency ordering for branch {color} | | {color:green}+1{color} | {color:green} mvninstall {color} | {color:green} 8m 33s{color} | {color:green} master passed {color} | | {color:green}+1{color} | {color:green} compile {color} | {color:green} 2m 9s{color} | {color:green} master passed {color} | | {color:green}+1{color} | {color:green} checkstyle {color} | {color:green} 1m 10s{color} | {color:green} master passed {color} | | {color:blue}0{color} | {color:blue} findbugs {color} | {color:blue} 0m 38s{color} | {color:blue} itests/hive-unit in master has 2 extant Findbugs warnings. {color} | | {color:blue}0{color} | {color:blue} findbugs {color} | {color:blue} 3m 51s{color} | {color:blue} ql in master has 2317 extant Findbugs warnings. {color} | | {color:blue}0{color} | {color:blue} findbugs {color} | {color:blue} 0m 36s{color} | {color:blue} service in master has 48 extant Findbugs warnings. {color} | | {color:green}+1{color} | {color:green} javadoc {color} | {color:green} 1m 36s{color} | {color:green} master passed {color} | || || || || {color:brown} Patch Compile Tests {color} || | {color:blue}0{color} | {color:blue} mvndep {color} | {color:blue} 0m 9s{color} | {color:blue} Maven dependency ordering for patch {color} | | {color:green}+1{color} | {color:green} mvninstall {color} | {color:green} 2m 26s{color} | {color:green} the patch passed {color} | | {color:green}+1{color} | {color:green} compile {color} | {color:green} 2m 4s{color} | {color:green} the patch passed {color} | | {color:green}+1{color} | {color:green} javac {color} | {color:green} 2m 4s{color} | {color:green} the patch passed {color} | | {color:green}+1{color} | {color:green} checkstyle {color} | {color:green} 0m 21s{color} | {color:green} The patch hive-unit passed checkstyle {color} | | {color:green}+1{color} | {color:green} checkstyle {color} | {color:green} 0m 38s{color} | {color:green} ql: The patch generated 0 new + 218 unchanged - 1 fixed = 218 total (was 219) {color} | | {color:green}+1{color} | {color:green} checkstyle {color} | {color:green} 0m 13s{color} | {color:green} The patch service passed checkstyle {color} | | {color:green}+1{color} | {color:green} whitespace {color} | {color:green} 0m 0s{color} | {color:green} The patch has no whitespace issues. {color} | | {color:green}+1{color} | {color:green} findbugs {color} | {color:green} 5m 30s{color} | {color:green} the patch passed {color} | | {color:green}+1{color} | {color:green} javadoc {color} | {color:green} 1m 34s{color} | {color:green} the patch passed {color} | || || || || {color:brown} Other Tests {color} || | {color:red}-1{color} | {color:red} asflicense {color} | {color:red} 0m 13s{color} | {color:red} The patch generated 2 ASF License warnings. {color} | | {color:black}{color} | {color:black} {color} | {color:black} 32m 43s{color} | {color:black} {color} | \\ \\ || Subsystem || Report/Notes || | Optional Tests | asflicense javac javadoc findbugs checkstyle compile | | uname | Linux hiveptest-server-upstream 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux | | Build tool | maven | | Personality | /data/hiveptest/working/yetus_PreCommit-HIVE-Build-14638/dev-support/hive-personality.sh | | git revision | master / a99be34 | | Default Java | 1.8.0_111 | | findbugs | v3.0.0 | | asflicense | http://104.198.109.242/logs//PreCommit-HIVE-Build-14638/yetus/patch-asflicense-problems.txt | | modules | C: itests/hive-unit ql service U: . | | Console output | http://104.198.109.242/logs//PreCommit-HIVE-Build-14638/yetus.txt | | Powered by | Apache Yetus http://yetus.apache.org | This message was automatically generated. > Async query execution can potentially fail if shared sessionHive is closed by > master thread. > -------------------------------------------------------------------------------------------- > > Key: HIVE-20682 > URL: https://issues.apache.org/jira/browse/HIVE-20682 > Project: Hive > Issue Type: Bug > Components: HiveServer2 > Affects Versions: 3.1.0, 4.0.0 > Reporter: Sankar Hariappan > Assignee: Sankar Hariappan > Priority: Major > Labels: pull-request-available > Attachments: HIVE-20682.01.patch, HIVE-20682.02.patch > > > *Problem description:* > The master thread initializes the *sessionHive* object in *HiveSessionImpl* > class when we open a new session for a client connection and by default all > queries from this connection shares the same sessionHive object. > If the master thread executes a *synchronous* query, it closes the > sessionHive object (referred via thread local hiveDb) if > {{Hive.isCompatible}} returns false and sets new Hive object in thread local > HiveDb but doesn't change the sessionHive object in the session. Whereas, > *asynchronous* query execution via async threads never closes the sessionHive > object and it just creates a new one if needed and sets it as their thread > local hiveDb. > So, the problem can happen in the case where an *asynchronous* query is being > executed by async threads refers to sessionHive object and the master thread > receives a *synchronous* query that closes the same sessionHive object. > Also, each query execution overwrites the thread local hiveDb object to > sessionHive object which potentially leaks a metastore connection if the > previous synchronous query execution re-created the Hive object. > *Possible Fix:* > We shall maintain an Atomic reference counter in the Hive object. We > increment the counter when somebody sets it in thread local hiveDb and > decrement it when somebody releases it. Only when the counter is down to 0, > we should close the connection. > Couple of cases to release the thread local hiveDb: > * When synchronous query execution in master thread re-creates Hive object > due to config change. We also, need to update the sessionHive object in the > current session as we releases it from thread local hiveDb of master thread. > * When async thread exits after completing execution or due to exception. > If the session is getting closed, it is guaranteed that the reference counter > is down to 0 as we forcefully close all the async operations and so we can > close the connection there. > cc [~pvary] -- This message was sent by Atlassian JIRA (v7.6.3#76005)