hadoop-hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Liyin Tang (JIRA)" <j...@apache.org>
Subject [jira] Updated: (HIVE-1647) Incorrect initialization of thread local variable inside IOContext ( implementation is not threadsafe )
Date Wed, 29 Sep 2010 18:59:33 GMT

     [ https://issues.apache.org/jira/browse/HIVE-1647?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Liyin Tang updated HIVE-1647:
-----------------------------

    Status: Open  (was: Patch Available)

> Incorrect initialization of thread local variable inside IOContext ( implementation is
not threadsafe ) 
> --------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-1647
>                 URL: https://issues.apache.org/jira/browse/HIVE-1647
>             Project: Hadoop Hive
>          Issue Type: Bug
>          Components: Server Infrastructure
>    Affects Versions: 0.6.0, 0.7.0
>            Reporter: Raman Grover
>            Assignee: Liyin Tang
>             Fix For: 0.7.0
>
>   Original Estimate: 0.17h
>  Remaining Estimate: 0.17h
>
> Bug in org.apache.hadoop.hive.ql.io.IOContext
> in relation to initialization of thread local variable.
>  
> public class IOContext {
>  
>   private static ThreadLocal<IOContext> threadLocal = new ThreadLocal<IOContext>(){
};
>  
>   static {
>     if (threadLocal.get() == null) {
>       threadLocal.set(new IOContext());
>     }
>   }
>  
> In a multi-threaded environment, the thread that gets to load the class first for the
JVM (assuming threads share the classloader),
> gets to initialize itself correctly by executing the code in the static block. Once the
class is loaded, 
> any subsequent threads would  have their respective threadlocal variable as null.  Since
IOContext
> is set during initialization of HiveRecordReader, In a scenario where multiple threads
get to acquire
>  an instance of HiveRecordReader, it would result in a NPE for all but the first thread
that gets to load the class in the VM.
>  
> Is the above scenario of multiple threads initializing HiveRecordReader a typical one
?  or we could just provide the following fix...
>  
>   private static ThreadLocal<IOContext> threadLocal = new ThreadLocal<IOContext>(){
>     protected synchronized IOContext initialValue() {
>       return new IOContext();
>     }  
>   };

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message