You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@oozie.apache.org by "Robert Kanter (JIRA)" <ji...@apache.org> on 2013/07/16 18:40:48 UTC

[jira] [Updated] (OOZIE-1456) MemoryLocks.getLock() doesn't work

     [ https://issues.apache.org/jira/browse/OOZIE-1456?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Robert Kanter updated OOZIE-1456:
---------------------------------

    Description: 
{code:java}
    private LockToken getLock(String resource, Type type, long wait) throws InterruptedException {
        ReentrantReadWriteLock lockEntry;
        synchronized (locks) {
            if (locks.containsKey(resource)) {
                lockEntry = locks.get(resource);
            }
            else {
                lockEntry = new ReentrantReadWriteLock(true);
                locks.put(resource, lockEntry);
            }
        }

        Lock lock = (type.equals(Type.READ)) ? lockEntry.readLock() : lockEntry.writeLock();

        if (wait == -1) {
            lock.lock();
        }
        else {
            if (wait > 0) {
                if (!lock.tryLock(wait, TimeUnit.MILLISECONDS)) {
                    return null;
                }
            }
            else {
                if (!lock.tryLock()) {
                    return null;
                }
            }
        }
        synchronized (locks) {
            if (!locks.containsKey(resource)) {
                locks.put(resource, lockEntry);
            }
        }
        return new LockToken(lockEntry, lock, resource);
    }
{code}
If there are 2 concurrent threads trying to acquire lock on same key and lock is free, both will get lockEntry = new ReentrantReadWriteLock(true); and both will get the same lock!

Here is the log from oozie:
2013-07-12 14:48:32,503 DEBUG CoordActionInputCheckXCommand:545 - USER[-] GROUP[-] TOKEN[-] APP[-] JOB[0012816-130326154523555-oozie-oozi-C] ACTION[0012816-130326154523555-oozie-oozi-C@154290] Acquired lock for [0012816-130326154523555-oozie-oozi-C] in [coord_action_input]
2013-07-12 14:48:32,503 DEBUG CoordMaterializeTransitionXCommand:545 - USER[fetl] GROUP[-] TOKEN[] APP[<coord name>] JOB[0012816-130326154523555-oozie-oozi-C] ACTION[-] Acquired lock for [0055279-130607113249683-oozie-oozi-C] in [coord_mater]

After this the materialization was stuck and we had to bounce oozie. Still need to figure out why this paused materialization

  was:
    private LockToken getLock(String resource, Type type, long wait) throws InterruptedException {
        ReentrantReadWriteLock lockEntry;
        synchronized (locks) {
            if (locks.containsKey(resource)) {
                lockEntry = locks.get(resource);
            }
            else {
                lockEntry = new ReentrantReadWriteLock(true);
                locks.put(resource, lockEntry);
            }
        }

        Lock lock = (type.equals(Type.READ)) ? lockEntry.readLock() : lockEntry.writeLock();

        if (wait == -1) {
            lock.lock();
        }
        else {
            if (wait > 0) {
                if (!lock.tryLock(wait, TimeUnit.MILLISECONDS)) {
                    return null;
                }
            }
            else {
                if (!lock.tryLock()) {
                    return null;
                }
            }
        }
        synchronized (locks) {
            if (!locks.containsKey(resource)) {
                locks.put(resource, lockEntry);
            }
        }
        return new LockToken(lockEntry, lock, resource);
    }

If there are 2 concurrent threads trying to acquire lock on same key and lock is free, both will get lockEntry = new ReentrantReadWriteLock(true); and both will get the same lock!

Here is the log from oozie:
2013-07-12 14:48:32,503 DEBUG CoordActionInputCheckXCommand:545 - USER[-] GROUP[-] TOKEN[-] APP[-] JOB[0012816-130326154523555-oozie-oozi-C] ACTION[0012816-130326154523555-oozie-oozi-C@154290] Acquired lock for [0012816-130326154523555-oozie-oozi-C] in [coord_action_input]
2013-07-12 14:48:32,503 DEBUG CoordMaterializeTransitionXCommand:545 - USER[fetl] GROUP[-] TOKEN[] APP[<coord name>] JOB[0012816-130326154523555-oozie-oozi-C] ACTION[-] Acquired lock for [0055279-130607113249683-oozie-oozi-C] in [coord_mater]

After this the materialization was stuck and we had to bounce oozie. Still need to figure out why this paused materialization

    
> MemoryLocks.getLock() doesn't work
> ----------------------------------
>
>                 Key: OOZIE-1456
>                 URL: https://issues.apache.org/jira/browse/OOZIE-1456
>             Project: Oozie
>          Issue Type: Bug
>            Reporter: Shwetha G S
>            Priority: Critical
>
> {code:java}
>     private LockToken getLock(String resource, Type type, long wait) throws InterruptedException {
>         ReentrantReadWriteLock lockEntry;
>         synchronized (locks) {
>             if (locks.containsKey(resource)) {
>                 lockEntry = locks.get(resource);
>             }
>             else {
>                 lockEntry = new ReentrantReadWriteLock(true);
>                 locks.put(resource, lockEntry);
>             }
>         }
>         Lock lock = (type.equals(Type.READ)) ? lockEntry.readLock() : lockEntry.writeLock();
>         if (wait == -1) {
>             lock.lock();
>         }
>         else {
>             if (wait > 0) {
>                 if (!lock.tryLock(wait, TimeUnit.MILLISECONDS)) {
>                     return null;
>                 }
>             }
>             else {
>                 if (!lock.tryLock()) {
>                     return null;
>                 }
>             }
>         }
>         synchronized (locks) {
>             if (!locks.containsKey(resource)) {
>                 locks.put(resource, lockEntry);
>             }
>         }
>         return new LockToken(lockEntry, lock, resource);
>     }
> {code}
> If there are 2 concurrent threads trying to acquire lock on same key and lock is free, both will get lockEntry = new ReentrantReadWriteLock(true); and both will get the same lock!
> Here is the log from oozie:
> 2013-07-12 14:48:32,503 DEBUG CoordActionInputCheckXCommand:545 - USER[-] GROUP[-] TOKEN[-] APP[-] JOB[0012816-130326154523555-oozie-oozi-C] ACTION[0012816-130326154523555-oozie-oozi-C@154290] Acquired lock for [0012816-130326154523555-oozie-oozi-C] in [coord_action_input]
> 2013-07-12 14:48:32,503 DEBUG CoordMaterializeTransitionXCommand:545 - USER[fetl] GROUP[-] TOKEN[] APP[<coord name>] JOB[0012816-130326154523555-oozie-oozi-C] ACTION[-] Acquired lock for [0055279-130607113249683-oozie-oozi-C] in [coord_mater]
> After this the materialization was stuck and we had to bounce oozie. Still need to figure out why this paused materialization

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira