Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispatcher logs ArrayIndexOutOfBoundsExceptions #813

Closed
JackSilk opened this issue Apr 16, 2021 · 4 comments · Fixed by #814
Closed

Dispatcher logs ArrayIndexOutOfBoundsExceptions #813

JackSilk opened this issue Apr 16, 2021 · 4 comments · Fixed by #814
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@JackSilk
Copy link

Describe the bug
The logs for the Kafka broker dispatcher show a lot of ArrayIndexOutOfBoundsExceptions.

Apr 14, 2021 1:41:08 PM io.vertx.core.impl.ContextImpl
SEVERE: Unhandled exception
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at dev.knative.eventing.kafka.broker.dispatcher.consumer.impl.UnorderedOffsetManager$OffsetTracker.recordNewOffset(UnorderedOffsetManager.java:207)
at dev.knative.eventing.kafka.broker.dispatcher.consumer.impl.UnorderedOffsetManager.recordDiscarded(UnorderedOffsetManager.java:109)
at dev.knative.eventing.kafka.broker.dispatcher.RecordDispatcher.onFilterNotMatching(RecordDispatcher.java:153)
at dev.knative.eventing.kafka.broker.dispatcher.RecordDispatcher.lambda$onRecordReceived$1(RecordDispatcher.java:137)
at io.vertx.core.impl.future.FutureBase.emit(FutureBase.java:96)
at io.vertx.core.impl.future.SucceededFuture.onSuccess(SucceededFuture.java:61)
at dev.knative.eventing.kafka.broker.dispatcher.RecordDispatcher.onRecordReceived(RecordDispatcher.java:132)
at dev.knative.eventing.kafka.broker.dispatcher.RecordDispatcher.apply(RecordDispatcher.java:116)
at dev.knative.eventing.kafka.broker.dispatcher.RecordDispatcher.handle(RecordDispatcher.java:126)
at dev.knative.eventing.kafka.broker.dispatcher.RecordDispatcher.handle(RecordDispatcher.java:40)
at io.vertx.kafka.client.consumer.impl.KafkaConsumerImpl.lambda$handler$1(KafkaConsumerImpl.java:81)
at io.vertx.kafka.client.consumer.impl.KafkaReadStreamImpl.lambda$null$10(KafkaReadStreamImpl.java:250)
at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:52)
at io.vertx.core.impl.DuplicatedContext.emit(DuplicatedContext.java:194)
at io.vertx.core.impl.AbstractContext.emit(AbstractContext.java:49)
at io.vertx.kafka.client.consumer.impl.KafkaReadStreamImpl.lambda$tracedHandler$11(KafkaReadStreamImpl.java:247)
at io.vertx.kafka.client.consumer.impl.KafkaReadStreamImpl.run(KafkaReadStreamImpl.java:237)
at io.vertx.kafka.client.consumer.impl.KafkaReadStreamImpl.lambda$schedule$8(KafkaReadStreamImpl.java:192)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:96)
at io.vertx.core.impl.AbstractContext.dispatch(AbstractContext.java:59)
at io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:40)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Unknown Source)

Expected behavior
No ArrayIndexOutOfBoundsExceptions

To Reproduce
Steps to reproduce the behavior.
Put a large-ish volume of events (1000s) through a broker + trigger, particularly if some of those

Knative release version
0.22

Additional context
UnorderedOffsetManager seems to try and make the array large enough to avoid this index out of bounds exception. I think it is just an off-by-one error - perhaps the check should be less-than-or-equal?
private void checkAcksArraySize(int blockIndex) { if (this.uncommitted.length < blockIndex) { // Let's make sure we create enough room for more unordered records this.uncommitted = Arrays.copyOf(this.uncommitted, (blockIndex + 1) * 2); } }

@JackSilk JackSilk added the kind/bug Categorizes issue or PR as related to a bug. label Apr 16, 2021
@slinkydeveloper
Copy link
Contributor

slinkydeveloper commented Apr 16, 2021

Yep I think that's the issue, it's strange that unit tests didn't caught it...

@slinkydeveloper
Copy link
Contributor

/assign

slinkydeveloper added a commit to slinkydeveloper/eventing-kafka-broker that referenced this issue Apr 16, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot pushed a commit that referenced this issue Apr 18, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
knative-prow-robot pushed a commit to knative-prow-robot/eventing-kafka-broker that referenced this issue Apr 18, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
@slinkydeveloper
Copy link
Contributor

We should get a new 0.22 release that fixes this bug, thanks for the help!

@JackSilk
Copy link
Author

Thank you for fixing it :)

knative-prow-robot added a commit that referenced this issue Apr 19, 2021
Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

Co-authored-by: slinkydeveloper <francescoguard@gmail.com>
creydr pushed a commit to creydr/knative-eventing-kafka-broker that referenced this issue Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants