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

László Bodor commented on TEZ-3967:
-----------------------------------

[~jeagles], [~gopalv], [~jeagles]: could you please look back to this patch 
once TEZ-4171 is resolved?
I can see the [^TEZ-3967.03.patch] basically solves a lock contention problem 
by generating dag status periodically and returning a cached value, however, 
regarding TEZ-4171 I realized again that the dag state enum is a "privileged" 
property, which should contain the most up-to-date value which is possible...
currently, in [^TEZ-3967.03.patch], i simply return the cached value like:
{code}
public DAGStatusBuilder getStatus() {
      countGetDagStatus += 1;
      return cachedDagStatusBuilder;
}
{code}

but I would change it in a way that force the returned state to be the latest 
(no matter of the additional read-lock compared to the original optimization), 
otherwise, this patch could ruin the optimization of e.g. TEZ-4171 I think
{code}
public DAGStatusBuilder getStatus() {
      countGetDagStatus += 1;
      cachedDagStatusBuilder.setState(getState());
      return cachedDagStatusBuilder;
}
{code}

I don't think I can optimize this further at the moment, only if we implement 
an endpoint which returns only the state, I guess most of the time while 
optimizing this part (e.g. TEZ-4171), client is only interested in the state, 
not the counters (querying it in every ~100ms)

 

> DAGImpl: dag lock is unfair and can starve the writers
> ------------------------------------------------------
>
>                 Key: TEZ-3967
>                 URL: https://issues.apache.org/jira/browse/TEZ-3967
>             Project: Apache Tez
>          Issue Type: Bug
>            Reporter: Gopal Vijayaraghavan
>            Assignee: László Bodor
>            Priority: Major
>         Attachments: TEZ-3967.01.patch, TEZ-3967.02.patch, TEZ-3967.03.patch
>
>
> Found when debugging HIVE-20103, that a reader arriving when another reader 
> is active can postpone a writer from obtaining a write-lock.
> This is fundamentally bad for the DAGImpl as useful progress can only happen 
> when the writeLock is held.
> {code}
>   public void handle(DAGEvent event) {
> ...
>     try {
>       writeLock.lock();
> {code}
> {code}
>    java.lang.Thread.State: WAITING (parking)
>         at sun.misc.Unsafe.park(Native Method)
>         - parking to wait for  <0x00007efb02246f40> (a 
> java.util.concurrent.locks.ReentrantReadWriteLock$NonfairSync)
>         at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)
>         at 
> java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199)
>         at 
> java.util.concurrent.locks.ReentrantReadWriteLock$WriteLock.lock(ReentrantReadWriteLock.java:943)
>         at org.apache.tez.dag.app.dag.impl.DAGImpl.handle(DAGImpl.java:1162)
>         at org.apache.tez.dag.app.dag.impl.DAGImpl.handle(DAGImpl.java:149)
>         at 
> org.apache.tez.dag.app.DAGAppMaster$DagEventDispatcher.handle(DAGAppMaster.java:2251)
>         at 
> org.apache.tez.dag.app.DAGAppMaster$DagEventDispatcher.handle(DAGAppMaster.java:2242)
>         at 
> org.apache.tez.common.AsyncDispatcher.dispatch(AsyncDispatcher.java:180)
>         at 
> org.apache.tez.common.AsyncDispatcher$1.run(AsyncDispatcher.java:115)
>         at java.lang.Thread.run(Thread.java:745)
> {code}
> while read-lock is passed around between 
> {code}
>        at 
> org.apache.tez.dag.app.dag.impl.DAGImpl.getDAGStatus(DAGImpl.java:901)
>         at 
> org.apache.tez.dag.app.dag.impl.DAGImpl.getDAGStatus(DAGImpl.java:940)
>         at 
> org.apache.tez.dag.api.client.DAGClientHandler.getDAGStatus(DAGClientHandler.java:73)
> {code}
> calls.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to