Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-28703

Data race in RecoveredEditsOutputSink while closing writers

    XMLWordPrintableJSON

Details

    • Reviewed

    Description

      Hit this error while testing jdk17 locally

      Tests run: 37, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 42.3 s <<< FAILURE! - in org.apache.hadoop.hbase.wal.TestWALSplitValueCompression
      org.apache.hadoop.hbase.wal.TestWALSplitValueCompression.testEmptyLogFiles  Time elapsed: 0.359 s  <<< ERROR!
      java.io.IOException: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 0
              at org.apache.hadoop.hbase.wal.RecoveredEditsOutputSink.closeWriters(RecoveredEditsOutputSink.java:129)
              at org.apache.hadoop.hbase.wal.RecoveredEditsOutputSink.close(RecoveredEditsOutputSink.java:96)
              at org.apache.hadoop.hbase.wal.WALSplitter.splitWAL(WALSplitter.java:416)
              at org.apache.hadoop.hbase.wal.WALSplitter.split(WALSplitter.java:219)
              at org.apache.hadoop.hbase.wal.TestWALSplit.splitAndCount(TestWALSplit.java:529)
              at org.apache.hadoop.hbase.wal.TestWALSplit.testEmptyLogFiles(TestWALSplit.java:563)
              at org.apache.hadoop.hbase.wal.TestWALSplit.testEmptyLogFiles(TestWALSplit.java:548)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.base/java.lang.reflect.Method.invoke(Method.java:568)
              at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
              at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
              at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
              at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
              at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
              at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
              at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:61)
              at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
              at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
              at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
              at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
              at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
              at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
              at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
              at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
              at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
              at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
              at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
              at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
              at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
              at java.base/java.lang.Thread.run(Thread.java:840)
      Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 0
              at java.base/java.util.ArrayList.add(ArrayList.java:455)
              at java.base/java.util.ArrayList.add(ArrayList.java:467)
              at org.apache.hadoop.hbase.wal.RecoveredEditsOutputSink.lambda$closeWriters$0(RecoveredEditsOutputSink.java:111)
              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
              at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
              at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
              at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
              at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
              ... 1 more
      

      It is a bit strange that we meet ArrayIndexOutOfBounds in ArrayList.add.

      Then I noticed that, we use a thread pool to close the writers but splits field is just an ArrayList, which is not thread safe...

      Attachments

        Activity

          People

            apurtell Andrew Kyle Purtell
            zhangduo Duo Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: