Uploaded image for project: 'Oozie'
  1. Oozie
  2. OOZIE-1922

MemoryLocksService fails if lock is acquired multiple times in same thread and released

VotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.3.0
    • None
    • None

    Description

      ReentrantLock can be acquired multiple times in same thread. For multiple acquire call, ReentrantLock hold count is incremented by one.
      So if we acquire lock multiple time from same thread, all will be successful and hold count is increased for every call.
      But if we release lock, MemoryLocksService ignore the count and deletes the lock. Even if it's held by some command.

      Simple step can reproduce it.

              service.getWriteLock("test", 5000); //writeHoldCount = 1
              MemoryLockToken lock = (MemoryLockToken)service.getWriteLock("test", 5000); //writeHoldCount = 2
              lock.release(); //writeHoldCount = 1
              lock = (MemoryLockToken)service.getWriteLock("test", 5000); //writeHoldCount = 1, it should be 2.
      
              @Override
              public void release() {
                  int val = rwLock.getQueueLength();
                  if (val == 0) {
                      synchronized (locks) {
                          locks.remove(resource);
                      }
                  }
                  lock.unlock();
              }
          }
      

      MemoryLocks should check hold count before removing lock.

      Attachments

        1. OOZIE-1922.1.patch
          5 kB
          seoeun
        2. OOZIE-1922.2.patch
          4 kB
          seoeun
        3. OOZIE-1922.3.patch
          4 kB
          seoeun
        4. OOZIE-1922-V1.patch
          13 kB
          Purshotam Shah
        5. OOZIE-1922-V2.patch
          12 kB
          Purshotam Shah
        6. OOZIE-1922-V3.patch
          12 kB
          Purshotam Shah

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            puru Purshotam Shah
            puru Purshotam Shah
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment