You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2020/02/21 13:08:33 UTC

[GitHub] [druid] pzhdfy opened a new pull request #9390: [bugfix]fix sequences ArrayIndexOutOfBoundsException in SeekableStreamIndexTaskRunner

pzhdfy opened a new pull request #9390: [bugfix]fix sequences ArrayIndexOutOfBoundsException in SeekableStreamIndexTaskRunner
URL: https://github.com/apache/druid/pull/9390
 
 
   ### Description
   
   getLastSequenceMetadata in SeekableStreamIndexTaskRunner
   
   `
   private SequenceMetadata<PartitionIdType, SequenceOffsetType> getLastSequenceMetadata()
     {
       Preconditions.checkState(!sequences.isEmpty(), "Empty sequences");
       return sequences.get(sequences.size() - 1);
     }
   `
   sequences may be removed items during size() and get()
   
   In our version, we meet error like this
   java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
   	at java.util.concurrent.CopyOnWriteArrayList.elementAt(CopyOnWriteArrayList.java:386) ~[?:?]
   	at java.util.concurrent.CopyOnWriteArrayList.get(CopyOnWriteArrayList.java:399) ~[?:?]
   	at io.druid.indexing.kafka.KafkaIndexTask.run(KafkaIndexTask.java:639) ~[druid-kafka-indexing-service-0.12.0.jar:0.12.0]
   	at io.druid.indexing.overlord.ThreadPoolTaskRunner$ThreadPoolTaskRunnerCallable.call(ThreadPoolTaskRunner.java:457) [druid-indexing-service-0.12.0.jar:0.12.0]
   	at io.druid.indexing.overlord.ThreadPoolTaskRunner$ThreadPoolTaskRunnerCallable.call(ThreadPoolTaskRunner.java:429) [druid-indexing-service-0.12.0.jar:0.12.0]
   	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
   	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
   	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
   	at java.lang.Thread.run(Thread.java:834) [?:?]
   
   so  we can make a copy first, and create a CopyOnWriteArrayList from a CopyOnWriteArrayList will not really copy data, so the overhead is acceptable.
   `
    private SequenceMetadata<PartitionIdType, SequenceOffsetType> getLastSequenceMetadata()
     {
       final CopyOnWriteArrayList<SequenceMetadata<PartitionIdType, SequenceOffsetType>> sequencesSnapshot = new CopyOnWriteArrayList<>(sequences);
       Preconditions.checkState(!sequencesSnapshot.isEmpty(), "Empty sequences");
       return sequencesSnapshot.get(sequencesSnapshot.size() - 1);
     }
   `
   This PR has:
   - [ ] been self-reviewed.
      - [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/licenses.yaml)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [ ] added unit tests or modified existing tests to cover new code paths.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist above are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `MyFoo`
    * `OurBar`
    * `TheirBaz`
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org