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

NullPointerException from MasterSlaveTopologyRefresh.java #1014

Closed
kas-kad opened this issue Apr 10, 2019 · 2 comments
Closed

NullPointerException from MasterSlaveTopologyRefresh.java #1014

kas-kad opened this issue Apr 10, 2019 · 2 comments
Labels
status: duplicate A duplicate of another issue type: bug A general bug

Comments

@kas-kad
Copy link

kas-kad commented Apr 10, 2019

Bug Report

Current Behavior

We had a successful Redis failover but the application didn't manage to handle it properly. Current setup is: 9 Sentinels, 1 Master, 3 Slaves.

First we had dozens of Timeout exceptions, that's ok:

io.lettuce.core.RedisCommandTimeoutException: Command timed out

Later on we get couple of these, which I don't think is ok:

java.lang.NullPointerException: null
	at io.lettuce.core.masterslave.MasterSlaveTopologyRefresh.getNodeSpecificViews(MasterSlaveTopologyRefresh.java:111)
	at io.lettuce.core.masterslave.MasterSlaveTopologyRefresh.getNodes(MasterSlaveTopologyRefresh.java:77)
	at io.lettuce.core.masterslave.MasterSlave.lambda$connectSentinel$0(MasterSlave.java:174)
	at java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:891)
	at io.lettuce.core.masterslave.SentinelTopologyRefresh.lambda$null$2(SentinelTopologyRefresh.java:149)
	at io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38)
	at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:125)
	at io.netty.util.concurrent.DefaultEventExecutor.run(DefaultEventExecutor.java:66)
	at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Thread.java:748)

After that we end up with infinite:

io.lettuce.core.RedisCommandExecutionException: READONLY You can't write against a read only replica.

Input Code

    private val redisUri: RedisURI by lazy {
        val redisUriBuilder = RedisURI.builder()
        sentinels
            .split(",")
            .forEach {
                val (host, port) = it.split(":")
                redisUriBuilder
                    .withSentinel(host, port.toInt())
                    .withSentinelMasterId(master)
                    .withDatabase(2)
                    .withTimeout(Duration.ofMillis(defaultTimeoutMillis))
            }
        redisUriBuilder.build()
    }

    private val connection: StatefulRedisMasterSlaveConnection<String, String> by lazy {
        val connection = MasterSlave
            .connect(client, Utf8StringCodec(), redisUri)
        connection.readFrom = ReadFrom.MASTER
        connection
    }

    private val client: RedisClient = RedisClient.create()

Expected behavior/code

The successful failover must not cause the application stop functioning.

Environment

  • Lettuce version(s): 5.0.1.RELEASE
  • Redis version: 5.0.3
@mp911de mp911de added the type: bug A general bug label Apr 11, 2019
@mp911de
Copy link
Collaborator

mp911de commented Apr 11, 2019

Thanks for reporting this bug.

@mp911de
Copy link
Collaborator

mp911de commented Apr 11, 2019

This issue was solved with #643 and Lettuce 5.1. Please upgrade to the latest version and retest.

@mp911de mp911de closed this as completed Apr 11, 2019
@mp911de mp911de added the status: duplicate A duplicate of another issue label Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants