[ 
https://issues.apache.org/jira/browse/HDDS-1672?focusedWorklogId=263984&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-263984
 ]

ASF GitHub Bot logged work on HDDS-1672:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Jun/19 18:18
            Start Date: 20/Jun/19 18:18
    Worklog Time Spent: 10m 
      Work Description: anuengineer commented on pull request #949: HDDS-1672. 
Improve locking in OzoneManager.
URL: https://github.com/apache/hadoop/pull/949#discussion_r295898352
 
 

 ##########
 File path: 
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OzoneManagerLock.java
 ##########
 @@ -96,30 +112,39 @@ public OzoneManagerLock(Configuration conf) {
   }
 
   /**
-   * Acquires user lock on the given resource.
+   * Acquires S3 Bucket lock on the given resource.
    *
    * <p>If the lock is not available then the current thread becomes
-   * disabled for thread scheduling purposes and lies dormant until the
-   * lock has been acquired.
+   * disabled for thread scheduling purposes and lies dormant until the lock 
has
+   * been acquired.
    *
-   * @param user User on which the lock has to be acquired
+   * @param s3BucketName S3Bucket Name on which the lock has to be acquired
    */
-  public void acquireUserLock(String user) {
-    // Calling thread should not hold any volume or bucket lock.
-    if (hasAnyVolumeLock() || hasAnyBucketLock() || hasAnyS3Lock()) {
+  public void acquireS3BucketLock(String s3BucketName) {
+    // Calling thread should not hold any volume/bucket/user lock.
+
+    // Not added checks for prefix/s3 secret lock, as they will never be
+    // taken with s3Bucket Lock. In this way, we can avoid 2 checks every
+    // time we acquire s3Bucket lock.
+
+    // Or do we need to add this for future safe?
+
+    if (hasAnyVolumeLock() || hasAnyBucketLock() || hasAnyUserLock()) {
 
 Review comment:
   if we do the bitmap trick, we can write a generic function that looks like 
this , hasAnyHigherLocks(UserLock), and this can check from 1-5 -- which is a 
series of simple xor operations and return the value. All we care is if the 
lock has been taken; so a simple bit map for each thread is all we need. 
Assuming that our lock hierarchy would not cross 32 locking levels 
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 263984)
    Time Spent: 3h  (was: 2h 50m)

> Improve locking in OzoneManager
> -------------------------------
>
>                 Key: HDDS-1672
>                 URL: https://issues.apache.org/jira/browse/HDDS-1672
>             Project: Hadoop Distributed Data Store
>          Issue Type: Improvement
>          Components: Ozone Manager
>    Affects Versions: 0.4.0
>            Reporter: Bharat Viswanadham
>            Assignee: Bharat Viswanadham
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: Ozone Locks in OM.pdf
>
>          Time Spent: 3h
>  Remaining Estimate: 0h
>
> In this Jira, we shall follow the new lock ordering. In this way, in volume 
> requests we can solve the issue of acquire/release/reacquire problem. And few 
> bugs in the current implementation of S3Bucket/Volume operations.
>  
> Currently after acquiring volume lock, we cannot acquire user lock. 
> This is causing an issue in Volume request implementation, 
> acquire/release/reacquire volume lock.
>  
> Case of Delete Volume Request: 
>  # Acquire volume lock.
>  # Get Volume Info from DB
>  # Release Volume lock. (We are releasing the lock, because while acquiring 
> volume lock, we cannot acquire user lock0
>  # Get owner from volume Info read from DB
>  # Acquire owner lock
>  # Acquire volume lock
>  # Do delete logic
>  # release volume lock
>  # release user lock
>  
> We can avoid this acquire/release/reacquire lock issue by making volume lock 
> as low weight. 
>  
> In this way, the above deleteVolume request will change as below
>  # Acquire volume lock
>  # Get Volume Info from DB
>  # Get owner from volume Info read from DB
>  # Acquire owner lock
>  # Do delete logic
>  # release owner lock
>  # release volume lock. 
> Same issue is seen with SetOwner for Volume request also.
> During HDDS-1620 [~arp] brought up this issue. 
> I am proposing the above solution to solve this issue. Any other 
> idea/suggestions are welcome.
> This also resolves a bug in setOwner for Volume request.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to