Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-14350 Procedure V2 Phase 2: Assignment Manager
  3. HBASE-16744

Procedure V2 - Lock procedures to allow clients to acquire locks on tables/namespaces/regions

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.0.0
    • None
    • None
    • Hide
       Lock for HBase Entity either a Table, a Namespace, or Regions.

      These are remote locks which live on master, and need periodic heartbeats to keep them alive. (Once we request the lock, internally an heartbeat thread will be started). If master doesn't receive the heartbeat in time, it'll release the lock and make it available to other users.

      Use {@link LockServiceClient} to build instances. Then call {@link #requestLock()}. {@link #requestLock} will contact master to queue the lock and start the heartbeat thread which will check lock's status periodically and once the lock is acquired, it will send the heartbeats to the master.

      Use {@link #await} or {@link #await(long, TimeUnit)} to wait for the lock to be acquired. Always call {@link #unlock()} irrespective of whether lock was acquired or not. If the lock was acquired, it'll be released. If it was not acquired, it is possible that master grants the lock in future and the heartbeat thread keeps it alive forever by sending heartbeats. Calling {@link #unlock()} will stop the heartbeat thread and cancel the lock queued on master.

      There are 4 ways in which these remote locks may be released/can be lost:
        * Call {@link #unlock}.
        * Lock times out on master: Can happen because of network issues, GC pauses, etc. Worker thread will call the given abortable as soon as it detects such a situation. Fail to contact master: If worker thread can not contact mater and thus fails to send heartbeat before the timeout expires, it assumes that lock is lost and calls the
       * abortable.
      Worker thread is interrupted.

      Use example:

       EntityLock lock = lockServiceClient.*Lock(...., "exampled lock", abortable);
        lock.requestLock();
        ....
         ....can do other initializations here since lock is 'asynchronous'...
       ....
       if (lock.await(timeout)) {
          ....logic requiring mutual exclusion
        }
         lock.unlock();
       
      Show
       Lock for HBase Entity either a Table, a Namespace, or Regions. These are remote locks which live on master, and need periodic heartbeats to keep them alive. (Once we request the lock, internally an heartbeat thread will be started). If master doesn't receive the heartbeat in time, it'll release the lock and make it available to other users. Use {@link LockServiceClient} to build instances. Then call {@link #requestLock()}. {@link #requestLock} will contact master to queue the lock and start the heartbeat thread which will check lock's status periodically and once the lock is acquired, it will send the heartbeats to the master. Use {@link #await} or {@link #await(long, TimeUnit)} to wait for the lock to be acquired. Always call {@link #unlock()} irrespective of whether lock was acquired or not. If the lock was acquired, it'll be released. If it was not acquired, it is possible that master grants the lock in future and the heartbeat thread keeps it alive forever by sending heartbeats. Calling {@link #unlock()} will stop the heartbeat thread and cancel the lock queued on master. There are 4 ways in which these remote locks may be released/can be lost:   * Call {@link #unlock}.   * Lock times out on master: Can happen because of network issues, GC pauses, etc. Worker thread will call the given abortable as soon as it detects such a situation. Fail to contact master: If worker thread can not contact mater and thus fails to send heartbeat before the timeout expires, it assumes that lock is lost and calls the  * abortable. Worker thread is interrupted. Use example:  EntityLock lock = lockServiceClient.*Lock(...., "exampled lock", abortable);   lock.requestLock();   ....    ....can do other initializations here since lock is 'asynchronous'...  ....  if (lock.await(timeout)) {     ....logic requiring mutual exclusion   }    lock.unlock();  

    Description

      Will help us get rid of ZK locks.
      Will be useful for external tools like hbck, future backup manager, etc.

      Attachments

        1. HBASE-16744.master.001.patch
          347 kB
          Apekshit Sharma
        2. HBASE-16744.master.002.patch
          347 kB
          Apekshit Sharma
        3. HBASE-16744.master.003.patch
          346 kB
          Apekshit Sharma
        4. HBASE-16744.master.004.patch
          363 kB
          Apekshit Sharma
        5. HBASE-16744.master.005.patch
          363 kB
          Apekshit Sharma
        6. HBASE-16744.master.006.patch
          361 kB
          Apekshit Sharma
        7. HBASE-16744.master.007.patch
          369 kB
          Apekshit Sharma
        8. HBASE-16744.master.008.patch
          370 kB
          Apekshit Sharma
        9. HBASE-16744.master.009.patch
          377 kB
          Apekshit Sharma
        10. HBASE-16744.master.010.patch
          384 kB
          Apekshit Sharma
        11. HBASE-16744.master.011.patch
          381 kB
          Apekshit Sharma
        12. HBASE-16744.master.012.patch
          616 kB
          Apekshit Sharma
        13. HBASE-16744.master.013.patch
          382 kB
          Apekshit Sharma
        14. HBASE-16744.master.014.patch
          365 kB
          Michael Stack
        15. HBASE-16744.master.015.patch
          422 kB
          Michael Stack
        16. HBASE-16744.master.016.patch
          422 kB
          Michael Stack
        17. HBASE-16744.master.017.patch
          438 kB
          Michael Stack
        18. HBASE-16744.master.018.patch
          361 kB
          Michael Stack
        19. HBASE-16744.master.019.patch
          362 kB
          Michael Stack
        20. HBASE-16744.master.020.patch
          362 kB
          Michael Stack

        Issue Links

          Activity

            People

              mbertozzi Matteo Bertozzi
              appy Apekshit Sharma
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: