hadoop-yarn-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wangda Tan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (YARN-2594) Potential deadlock in RM when querying ApplicationResourceUsageReport
Date Fri, 26 Sep 2014 03:26:34 GMT

    [ https://issues.apache.org/jira/browse/YARN-2594?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14148676#comment-14148676
] 

Wangda Tan commented on YARN-2594:
----------------------------------

[~zxu],
Thanks for the explanation, it's very helpful, now I can understand write lock can block read
lock.

I've created a test program:
{code}
package sandbox;

import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;

public class Tester {
  private static class ReadThread implements Runnable {
    private String name;
    private ReadLock readLock;
    
    ReadThread(String name, ReadLock readLock) {
      this.name = name;
      this.readLock = readLock;
    }
    @Override
    public void run() {
      System.out.println("try lock read - " + name);
      readLock.lock();
      System.out.println("lock read - " + name);
    }
  }
  private static class WriteThread implements Runnable {
    private String name;
    private WriteLock writeLock;
    
    WriteThread(String name, WriteLock writeLock) {
      this.name = name;
      this.writeLock = writeLock;
    }
    
    @Override
    public void run() {
      System.out.println("try lock write - " + name);
      writeLock.lock();
      System.out.println("lock write - " + name);
    }
  }
  
  public static void main(String[] args) throws InterruptedException {
    ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
    ReadLock readLock = lock.readLock();
    WriteLock writeLock = lock.writeLock();
    
    Thread r1 = new Thread(new ReadThread("1", readLock));
    Thread r2 = new Thread(new ReadThread("2", readLock));
    Thread w = new Thread(new WriteThread("3", writeLock));
    
    r1.start();
    Thread.sleep(100);
    w.start();
    Thread.sleep(100);
    r2.start();
  }
}
{code}

Exactly as you described, a waiting write lock will block read block to avoid starvation.

> Potential deadlock in RM when querying ApplicationResourceUsageReport
> ---------------------------------------------------------------------
>
>                 Key: YARN-2594
>                 URL: https://issues.apache.org/jira/browse/YARN-2594
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: resourcemanager
>    Affects Versions: 2.6.0
>            Reporter: Karam Singh
>            Assignee: Wangda Tan
>            Priority: Blocker
>         Attachments: YARN-2594.patch
>
>
> ResoruceManager sometimes become un-responsive:
> There was in exception in ResourceManager log and contains only  following type of messages:
> {code}
> 2014-09-19 19:13:45,241 INFO  event.AsyncDispatcher (AsyncDispatcher.java:handle(232))
- Size of event-queue is 53000
> 2014-09-19 19:30:26,312 INFO  event.AsyncDispatcher (AsyncDispatcher.java:handle(232))
- Size of event-queue is 54000
> 2014-09-19 19:47:07,351 INFO  event.AsyncDispatcher (AsyncDispatcher.java:handle(232))
- Size of event-queue is 55000
> 2014-09-19 20:03:48,460 INFO  event.AsyncDispatcher (AsyncDispatcher.java:handle(232))
- Size of event-queue is 56000
> 2014-09-19 20:20:29,542 INFO  event.AsyncDispatcher (AsyncDispatcher.java:handle(232))
- Size of event-queue is 57000
> 2014-09-19 20:37:10,635 INFO  event.AsyncDispatcher (AsyncDispatcher.java:handle(232))
- Size of event-queue is 58000
> 2014-09-19 20:53:51,722 INFO  event.AsyncDispatcher (AsyncDispatcher.java:handle(232))
- Size of event-queue is 59000
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message