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

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

ayushtkn commented on code in PR #5591:
URL: https://github.com/apache/hadoop/pull/5591#discussion_r1176752550


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestObserverNode.java:
##########
@@ -583,7 +583,6 @@ public void testMkdirsRaceWithObserverRead() throws 
Exception {
       futures[i] = threadPool.submit(new MkDirRunner(conf2, clientStates[i]));
     }
 
-    Thread.sleep(150); // wait until mkdir is logged

Review Comment:
   Can we just use GenricTestUtils.waitFor for this case, wait until mkdir gets 
actually gets logged?





> Fix testMkdirsRaceWithObserverRead
> ----------------------------------
>
>                 Key: HDFS-16991
>                 URL: https://issues.apache.org/jira/browse/HDFS-16991
>             Project: Hadoop HDFS
>          Issue Type: Bug
>          Components: hdfs
>    Affects Versions: 3.3.4
>            Reporter: fanluo
>            Priority: Minor
>              Labels: pull-request-available
>
> The test case testMkdirsRaceWithObserverRead which in TestObserverNode 
> sometimes failed like this:
> {code:java}
> java.lang.AssertionError: Client #1 lastSeenStateId=-9223372036854775808 
> activStateId=5
> null    at org.junit.Assert.fail(Assert.java:89)
>     at org.junit.Assert.assertTrue(Assert.java:42)
>     at 
> org.apache.hadoop.hdfs.server.namenode.ha.TestObserverNode.testMkdirsRaceWithObserverRead(TestObserverNode.java:607)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>     at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>     at java.lang.reflect.Method.invoke(Method.java:498)
>     at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
>     at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>  {code}
> i think the Thread.sleep() should move into the sub threads, like this:
> {code:java}
> public void run() {
>   try {
>     fs.mkdirs(DIR_PATH);
>     Thread.sleep(150); // wait until mkdir is logged
>     clientState.lastSeenStateId = HATestUtil.getLastSeenStateId(fs);
>     assertSentTo(fs, 0);    FileStatus stat = fs.getFileStatus(DIR_PATH);
>     assertSentTo(fs, 2);
>     assertTrue("Should be a directory", stat.isDirectory());
>   } catch (FileNotFoundException ioe) {
>     clientState.fnfe = ioe;
>   } catch (Exception e) {
>     fail("Unexpected exception: " + e);
>   }
> } {code}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to