Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-12431

Use of getColumnLatestCell(byte[], int, int, byte[], int, int) is Not Thread Safe

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.98.1
    • 1.0.0, 0.98.9
    • Client
    • None
    • Reviewed

    Description

      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.

      Attachments

        1. HBASE-12431.diff
          2 kB
          Jingcheng Du
        2. HBASE-12431-V2.diff
          1 kB
          Jingcheng Du
        3. HBASE-12431-V3.diff
          1 kB
          Jingcheng Du

        Activity

          People

            jingcheng.du@intel.com Jingcheng Du
            jon_apache Jonathan Jarvis
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: