hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jingcheng Du (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-12431) Use of getColumnLatestCell(byte[], int, int, byte[], int, int) is Not Thread Safe
Date Thu, 06 Nov 2014 11:51:34 GMT

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

Jingcheng Du commented on HBASE-12431:
--------------------------------------

Thanks Anoop [~anoopsamjohn] for the review.

bq. Why can't we have a ThreadLocal<byte[]> ?
ThreadLocal<byte[]> works, will upload a new patch to fix it.

bq. I don't think even after this fix we will be thread safe. Same Result object can not be
used by multiple threads.
I think it'll be thread safe after the buffer is a thread-local. Anyway will leave the NOT
THREAD SAFE in the comments.

bq. Any chance you got to run the perf test in TestResult?
Not yet, will run the test and post the result.

> Use of getColumnLatestCell(byte[], int, int, byte[], int, int) is Not Thread Safe
> ---------------------------------------------------------------------------------
>
>                 Key: HBASE-12431
>                 URL: https://issues.apache.org/jira/browse/HBASE-12431
>             Project: HBase
>          Issue Type: Bug
>          Components: Client
>    Affects Versions: 0.98.1
>            Reporter: Jonathan Jarvis
>            Assignee: Jingcheng Du
>            Priority: Critical
>         Attachments: HBASE-12431.diff
>
>
> Result declares that it is NOT THREAD SAFE at the top of the source code, but one would
assume that refers to many different threads accessing the same Result object. I've run into
an issue when I have several different threads accessing their own Result object that runs
into an issue because of use of common static member variable.
> I noticed the problem when I switched from:
> getColumnLatestCell(byte[], byte[]) to
> getColumnLatestCell(byte[], int, int, byte[], int, int)
> These methods call different binarySearch methods, the latter invoking:
> protected int  binarySearch(final Cell [] kvs,
> 309      final byte [] family, final int foffset, final int flength,
> 310      final byte [] qualifier, final int qoffset, final int qlength) {
> This method utilizes a private static member variable called "buffer"
> If more than one thread is utilizing "buffer" you'll see unpredictable behavior unless
you synchronize(Result.class) {}.
> If buffer is to remain a static variable, I would recommend changing it to a ThreadLocal<byte[]>
instead.



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

Mime
View raw message