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

ArrayIndexOutOfBoundsException in a connection to Redis #58

Closed
milen-georgiev-axway opened this issue Oct 8, 2021 · 4 comments
Closed
Labels

Comments

@milen-georgiev-axway
Copy link

Hi there,

We use Sprint WebFlux with Lettuce for Redis connections. We 've had an incident with a frozen Lettuce thread, because of
java.lang.ArrayIndexOutOfBoundsException at at org.davidmoten.rx.pool.MemberSingle.tryEmit(MemberSingle.java:276)

Please advise.

Here is the stacktrace:

stack_trace
java.lang.NullPointerException: subscribeActual failed
at io.reactivex.Single.subscribe(Single.java:3671)
at io.reactivex.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:34)
at io.reactivex.Single.subscribe(Single.java:3666)
at io.reactivex.internal.operators.single.SingleToFlowable.subscribeActual(SingleToFlowable.java:37)
at io.reactivex.Flowable.subscribe(Flowable.java:14935)
at io.reactivex.internal.operators.flowable.FlowableFlatMap.subscribeActual(FlowableFlatMap.java:53)
at io.reactivex.Flowable.subscribe(Flowable.java:14935)
at io.reactivex.Flowable.subscribe(Flowable.java:14885)
at reactor.core.publisher.MonoFromPublisher.subscribe(MonoFromPublisher.java:63)
at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.MonoMetrics$MetricsSubscriber.onNext(MonoMetrics.java:127)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.FluxUsingWhen$UsingWhenSubscriber.onNext(FluxUsingWhen.java:358)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:250)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.innerNext(FluxConcatMap.java:281)
at reactor.core.publisher.FluxConcatMap$ConcatMapInner.onNext(FluxConcatMap.java:860)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:73)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:120)
at com.axway.salesforcePanelService.utils.MDCSubscriberWrapper.onNext(MDCUtils.kt:75)
at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
at reactor.core.publisher.MonoNext$NextSubscriber.onNext(MonoNext.java:82)
at io.lettuce.core.RedisPublisher$ImmediateSubscriber.onNext(RedisPublisher.java:886)
at io.lettuce.core.RedisPublisher$RedisSubscription.onNext(RedisPublisher.java:291)
at io.lettuce.core.RedisPublisher$SubscriptionCommand.doOnComplete(RedisPublisher.java:773)
at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:65)
at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:63)
at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:742)
at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:677)
at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:594)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
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.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.davidmoten.rx.pool.MemberSingle.tryEmit(MemberSingle.java:276)
at org.davidmoten.rx.pool.MemberSingle.drain(MemberSingle.java:190)
at org.davidmoten.rx.pool.MemberSingle.subscribeActual(MemberSingle.java:113)
at io.reactivex.Single.subscribe(Single.java:3666)
... 60 common frames omitted

thread_name
lettuce-nioEventLoop-7-1

==============================

This is part of build.gradle

plugins {
id("org.springframework.boot") version "2.4.7"
id("io.spring.dependency-management") version "1.0.11.RELEASE"
id("com.gorylenko.gradle-git-properties") version "2.2.4"

kotlin("jvm") version "1.4.30"
kotlin("plugin.spring") version "1.4.30"

}

ext["snakeyaml.version"] = "1.28"
ext["netty.version"] = "4.1.63.Final"

allprojects {
repositories {
mavenCentral()
jcenter()
}

dependencyManagement {
    dependencies {
        dependency("commons-io:commons-io:2.7")
    }
}

}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-redis-reactive")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("io.micrometer:micrometer-registry-jmx")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

implementation("org.apache.commons:commons-text:1.8")

implementation("org.apache.commons:commons-lang3")
implementation("commons-codec:commons-codec")
implementation("commons-cli:commons-cli:1.4")

implementation("net.logstash.logback:logstash-logback-encoder:5.0")

implementation("com.github.davidmoten:rxjava2-jdbc:0.2.7")
implementation("org.postgresql:postgresql:42.2.19")

testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.projectreactor:reactor-test")
testImplementation("it.ozimov:embedded-redis:0.7.1")
testImplementation("org.assertj:assertj-core:3.18.1")

}

@davidmoten
Copy link
Owner

davidmoten commented Oct 10, 2021

Thanks for the report @milen-georgiev-axway. Can you review the fix #59 please? Once it has the tick I'll build a new release.

@davidmoten davidmoten added the bug label Oct 10, 2021
davidmoten added a commit that referenced this issue Oct 10, 2021
…#59

* fix race condition with disposal in MemberSingle.tryEmit #58
* organize imports
@davidmoten
Copy link
Owner

Thanks for reviewing. I didn't wait for an Approved tick from you as that was the only question. You are welcome to make more comments on the PR if you have any of course.

I've released 0.2.9 to Maven Central with the fix for this issue (actually 0.2.8 has that) and also includes an upgrade to latest rxjava2.

@milen-georgiev-axway
Copy link
Author

milen-georgiev-axway commented Oct 11, 2021

Thank you very much Dave, for your quick reaction!
Just wondering, when can we expect the new version artifact to be available on Maven?

@davidmoten
Copy link
Owner

0.2.9 is already there. Not visible if you search but download works. It's usually available for download 10mins after I release and then the index for search happens within 24 hours or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants