Skip to content

Cannot connect to Redis Sentinel using database greater 0 through Jedis #2103

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

Closed
steam0 opened this issue Jun 28, 2021 · 3 comments
Closed
Assignees
Labels
in: jedis Jedis driver type: regression A regression from a previous release

Comments

@steam0
Copy link

steam0 commented Jun 28, 2021

Hello,

I have previously asked this question directly to the Jedis-team redis/jedis#2567 but I don't really understand what is happening here. There are a few questions that I need to get adressed.

1. Is it supposed to be possible to use Redis sentinels and a specific Redis database (db > 0)?

While trying to connect to Redis using Sentinel and having the database property set to any number greater than 0, the applicaiton crashes. (Spring Boot 2.5.1, Spring Data Redis 2.5.1, Jedis 3.6.0) It seems like the new Jedis(hap.getHost(), hap.getPort(), sentinelConnectionTimeout, sentinelSoTimeout) line inside JedisSentinelPool.java in Jedis 3.6.0 crashes because we are trying to set the database number in redis sentinel rather than in the redis master node. See more in the jedis bug posted above.

Example configuration:

       @Bean
	fun jedisConnectionFactory(): RedisConnectionFactory? {
		val sentinelConfig = RedisSentinelConfiguration()
			.master("<your sentinel master>")
			.sentinel("<your sentinel server>", 26379)

		// This is the config creating the error, comment this in/out to test
		sentinelConfig.database = 2

		return JedisConnectionFactory(sentinelConfig)
	}

2. If we are supposed to use Redis sentinels and a specific database (db > 0), then how do I configure that?

Since configuring the sentinelConfig with a database number breaks the application, where and when should I do it?

Thank you so much in advance.

Demo app is attached below that show the problem.
demo-app.zip

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 28, 2021
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 28, 2021
@mp911de
Copy link
Member

mp911de commented Jun 28, 2021

Thanks for the report. The bug is on our side. Since the introduction of JedisClientConfig, we erroneously set the database number for the configuration object that is used to specify the Sentinel-specific node configuration. The only workaround would be using Lettuce instead of Jedis since Lettuce doesn't have that bug on its code path to initialize the client.

@steam0
Copy link
Author

steam0 commented Jun 28, 2021

But is the bug on your side Spring Data Redis or is it a bug in the client lib Jedis? If it is on your side, I will just wait until a fix is ready (which I believe won't take months and months?)

@mp911de
Copy link
Member

mp911de commented Jun 28, 2021

It's on our side. The next releases are scheduled for late July (https://calendar.spring.io/).

@mp911de mp911de added type: regression A regression from a previous release and removed type: bug A general bug labels Jun 30, 2021
@mp911de mp911de changed the title Error while using Redis Sentinel and database numbers greater than 0 Cannot connect to Redis Sentinel using database greater 0 through Jedis Jul 2, 2021
@mp911de mp911de added the in: jedis Jedis driver label Jul 2, 2021
@mp911de mp911de self-assigned this Jul 2, 2021
mp911de added a commit that referenced this issue Jul 2, 2021
…d for Sentinels.

We now no longer configure the database number configured for data node access through JedisClientConfiguration instances that are used for Sentinel node connectivity. Previously, the configured database number lead to issuing a SELECT command on Sentinel that doesn't support database isolation.

Fixes #2103.
christophstrobl pushed a commit that referenced this issue Jul 2, 2021
…d for Sentinels.

We now no longer configure the database number configured for data node access through JedisClientConfiguration instances that are used for Sentinel node connectivity. Previously, the configured database number lead to issuing a SELECT command on Sentinel that doesn't support database isolation.

Fixes: #2103.
Original Pull Request: #2112
@christophstrobl christophstrobl added this to the 2.5.3 (2021.0.3) milestone Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: jedis Jedis driver type: regression A regression from a previous release
Projects
None yet
4 participants