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

Improve IdLock and remove its minor defects

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • None
    • None
    • None
    • None

    Description

      Combination of synchronizations and concurrent collections complicates the code, and it is hard to trace the code and to confirm its correctness. We should re-create the class and make it more understandable.

      In the current code, I find the following minor defects:

      (1) In the case that there is a waiting thread for a lock in getLockEntry() and another thread is releasing the lock by calling releaseLockEntry(), trying to get the lock with a 3rd thread by calling getLockEntry() falls into a busy loop until the waiting thread wakes up and gets the lock.

      Even if notify() wakes up the blocked thread and causes a context switch to the waked thread immediately, synchronization might block the waked thread and cause another context switch, and the busy loop might continue for a while.

      (2) In the same case as (1), since releasing the lock is merely notifying without removing the lock-entry from the map, interrupting the waiting thread might leave an unused lock-entry (entry.numWaiters == 0) in the map. This is a memory leak unless the id of the lock is used again.

      Attachments

        1. HBASE-7160-V4.patch
          46 kB
          Hiroshi Ikeda
        2. HBASE-7160-V3.patch
          46 kB
          Hiroshi Ikeda
        3. HBASE-7160-V2.patch
          21 kB
          Hiroshi Ikeda
        4. HBASE-7160.patch
          7 kB
          Hiroshi Ikeda

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ikeda Hiroshi Ikeda
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: