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

ConnectionSelectionStrategy not working as expected #502

Open
khushwaqt opened this issue Sep 22, 2022 · 1 comment
Open

ConnectionSelectionStrategy not working as expected #502

khushwaqt opened this issue Sep 22, 2022 · 1 comment
Assignees

Comments

@khushwaqt
Copy link

Describe the bug
I have decided to use StackExchange.Redis.Extension due to its connection pooling feature. Currently i am testing it in one of my project but not getting expected results. I have 2 redis servers (no master slave, no cluster ,no sentinel) and want to use both as active active with round robin Strategy. But despite of adding both IPs in configuration and even adding both configuration all keys are written into 1st instance of redis and there are no keys on 2nd instance.

To Reproduce
2 standalone redis servers connected to asp.net core application.

Expected behavior
While using round robin Strategy, 1 request should go to the Redis1 and other to Redis2 instance. Similarly when 1st instance of redis is shutdown then it also throws exception, while if 1st instance of redis is down then request should be entertained by 2nd instance.

Screenshots / StackTrace
Here is implementation 1. Round robin not working but switching to 2nd instance if 1st instance goes down.
` var configurations = new[]
{
new RedisConfiguration
{
AbortOnConnectFail = true,
Hosts = new[] {
new RedisHost { Host = "172.21.21.105", Port = 6379 },
new RedisHost { Host = "172.21.21.106", Port = 6379 },
},
AllowAdmin = true,
ConnectTimeout = 5000,
Database = 0,
PoolSize = 100,
IsDefault = true,
Name = "Instance1",
ConnectionSelectionStrategy=ConnectionSelectionStrategy.RoundRobin,
ServerEnumerationStrategy =serverEnumartions
},'

Implementation2 Round Robin not working also not switching to 2nd instance when 1st instance goes down.
` var configurations = new[]
{
new RedisConfiguration
{
AbortOnConnectFail = true,
Hosts = new[] {
new RedisHost { Host = "172.21.21.106", Port = 6379 },
},
AllowAdmin = true,
ConnectTimeout = 5000,
Database = 0,
PoolSize = 100,
IsDefault = true,
Name = "Instance1",
ConnectionSelectionStrategy=ConnectionSelectionStrategy.RoundRobin,
ServerEnumerationStrategy =serverEnumartions
},
new RedisConfiguration
{
AbortOnConnectFail = true,
Hosts = new[] { new RedisHost { Host = "172.21.21.107", Port = 6379 } },
AllowAdmin = true,
ConnectTimeout = 5000,
Database = 0,
PoolSize = 100,
Name = "Instance2",
ConnectionSelectionStrategy=ConnectionSelectionStrategy.RoundRobin,
ServerEnumerationStrategy =serverEnumartions
}'

Environment:

  • OS: Redis instance on RHEL-7
  • Runtime version [.NET Core 6.0 ....]
    -Application running from windows 10 machine.
imperugo pushed a commit that referenced this issue Dec 25, 2023
@imperugo
Copy link
Owner

Hi @khushwaqt

we release the 10.0.2 that should contains a fix for the issue you got.

Here #579 the explaination and the fix.

Could you try it and let us know?
Thanks

@imperugo imperugo self-assigned this Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants