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

ASF GitHub Bot commented on HDFS-17334:
---------------------------------------

hfutatzhanghb commented on PR #6434:
URL: https://github.com/apache/hadoop/pull/6434#issuecomment-1898012100

   > > > Line211 has already ensured that we have a monitor for this object:
   > > > 
https://github.com/apache/hadoop/blob/ba6ada73acc2bce560878272c543534c21c76f22/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogAsync.java#L211-L223
   > > > 
   > > > So, I think the description in this PR is not a problem. What's your 
opinion? @hfutatzhanghb
   > > 
   > > 
   > > @zhangshuyan0 Sir, `this.wait(1000);` is in do-while loop, when we 
invoke `this.wait(1000)` at first time, it will release object monitor. But in 
extreme situation, it will throw Exception when invoke `this.wait(1000)` at the 
second time, because current thread does not hold the object monitor. Waiting 
for your response~
   > 
   > Let's see [java 
doc](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-)
 :
   > 
   > > Thus, on return from the wait method, the synchronization state of the 
object and of thread T is exactly as it was when the wait method was invoked.
   > 
   > Therefore, after `this.wait(1000)` returns at first time, it obtains the 
monitor again. I think no exception will be thrown here. By the way, in this 
[java 
doc](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-)
 , `synchronized -> while loop` is showed as a recommended usage. Looking 
forward to your response.
   
   Sir, Thanks a lot for your explanations here.  I will close this PR laterly. 
Thanks again.




> FSEditLogAsync#enqueueEdit does not synchronized this before invoke wait 
> method
> -------------------------------------------------------------------------------
>
>                 Key: HDFS-17334
>                 URL: https://issues.apache.org/jira/browse/HDFS-17334
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: namenode
>    Affects Versions: 3.3.6
>            Reporter: farmmamba
>            Assignee: farmmamba
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 3.5.0
>
>
> In method FSEditLogAsync#enqueueEdit , there exist the below codes:
> {code:java}
>         if (Thread.holdsLock(this)) {
>           // if queue is full, synchronized caller must immediately relinquish
>           // the monitor before re-offering to avoid deadlock with sync thread
>           // which needs the monitor to write transactions.
>           int permits = overflowMutex.drainPermits();
>           try {
>             do {
>               this.wait(1000); // will be notified by next logSync.
>             } while (!editPendingQ.offer(edit));
>           } finally {
>             overflowMutex.release(permits);
>           }
>         }  {code}
> It maybe invoke this.wait(1000) without having object this's monitor.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to