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

UpdateSentinelAddressList is failing with error: EndPoints must be unique #1430

Closed
ejsmith opened this issue Apr 12, 2020 · 4 comments
Closed

Comments

@ejsmith
Copy link
Contributor

ejsmith commented Apr 12, 2020

I am getting the following error attempting to use sentinel support. I'm guessing this is some sort of concurrency issue, but I'm not sure. I will try and get a repro together.

EndPoints must be unique (Parameter 'item')
System.ArgumentException: EndPoints must be unique (Parameter 'item')
   at StackExchange.Redis.EndPointCollection.InsertItem(Int32 index, EndPoint item) in /_/src/StackExchange.Redis/EndPointCollection.cs:line 71
   at StackExchange.Redis.ConnectionMultiplexer.UpdateSentinelAddressList(String serviceName) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2400
   at StackExchange.Redis.ConnectionMultiplexer.SwitchMaster(EndPoint switchBlame, ConnectionMultiplexer connection, TextWriter log) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2376
   at StackExchange.Redis.ConnectionMultiplexer.GetSentinelMasterConnection(ConfigurationOptions config, TextWriter log) in /_/src/StackExchange.Redis/ConnectionMultiplexer.cs:line 2255
   at Exceptionless.Insulation.Bootstrapper.GetRedisConnection(Dictionary`2 options) in /app/src/Exceptionless.Insulation/Bootstrapper.cs:line 166
@ejsmith
Copy link
Contributor Author

ejsmith commented Apr 12, 2020

Is there any reason why EndPointCollection.InsertItem wouldn't just return if the item is already in the collection? I don't really understand why you would want to blow up. Seems like there is no harm in basically ensuring that an item is in the collection.

@ejsmith
Copy link
Contributor Author

ejsmith commented Apr 12, 2020

I guess maybe just because you are expecting to insert it at a specific index and if it already exists in another index position then it can not complete the requested operation.

ejsmith added a commit to ejsmith/StackExchange.Redis that referenced this issue Apr 12, 2020
…r for working with sentinel setups (StackExchange#1427) Fix issue with duplicate endpoints being added in the UpdateSentinelAddressList method (StackExchange#1430).
@ejsmith
Copy link
Contributor Author

ejsmith commented Apr 12, 2020

I added a TryAdd method to the EndPointCollection class that just adds the endpoint if it doesn't already exist.

ejsmith added a commit to ejsmith/StackExchange.Redis that referenced this issue Apr 13, 2020
…r for working with sentinel setups (StackExchange#1427) Fix issue with duplicate endpoints being added in the UpdateSentinelAddressList method (StackExchange#1430).

Add string configuration overloads for sentinel connect methods. Remove password from sentinel servers as it seems the windows port does not support it. Add some new tests.


Oops commented out the wrong line
ejsmith added a commit to ejsmith/StackExchange.Redis that referenced this issue Apr 13, 2020
…r for working with sentinel setups (StackExchange#1427) Fix issue with duplicate endpoints being added in the UpdateSentinelAddressList method (StackExchange#1430).

Add string configuration overloads for sentinel connect methods. Remove password from sentinel servers as it seems the windows port does not support it. Add some new tests.


Oops commented out the wrong line


Again
ejsmith added a commit to ejsmith/StackExchange.Redis that referenced this issue Apr 13, 2020
…r for working with sentinel setups (StackExchange#1427) Fix issue with duplicate endpoints being added in the UpdateSentinelAddressList method (StackExchange#1430).

Add string configuration overloads for sentinel connect methods. Remove password from sentinel servers as it seems the windows port does not support it. Add some new tests.
ejsmith added a commit to ejsmith/StackExchange.Redis that referenced this issue Apr 13, 2020
…r for working with sentinel setups (StackExchange#1427) Fix issue with duplicate endpoints being added in the UpdateSentinelAddressList method (StackExchange#1430).

Add string configuration overloads for sentinel connect methods. Remove password from sentinel servers as it seems the windows port does not support it. Add some new tests.
ejsmith added a commit to ejsmith/StackExchange.Redis that referenced this issue Apr 13, 2020
…r for working with sentinel setups (StackExchange#1427) Fix issue with duplicate endpoints being added in the UpdateSentinelAddressList method (StackExchange#1430).

Add string configuration overloads for sentinel connect methods. Remove password from sentinel servers as it seems the windows port does not support it. Add some new tests.
ejsmith added a commit to ejsmith/StackExchange.Redis that referenced this issue Apr 26, 2020
…r for working with sentinel setups (StackExchange#1427) Fix issue with duplicate endpoints being added in the UpdateSentinelAddressList method (StackExchange#1430).

Add string configuration overloads for sentinel connect methods. Remove password from sentinel servers as it seems the windows port does not support it. Add some new tests.
NickCraver pushed a commit that referenced this issue Jun 8, 2020
Add SentinelConnect and SentinelMasterConnect to ConnectionMultiplexer for working with sentinel setups (#1427)
Fix issue with duplicate endpoints being added in the UpdateSentinelAddressList method (#1430).

This change makes it a lot easier and more discoverable how to connect to a sentinel server while also allowing connecting with just a connection string change which allows existing libs that are using SE.Redis to be used in sentinel mode.

Adding a `serviceName` parameter to the connection string triggers sentinel mode. It will connect to the sentinel and discover the current master and return a managed connection that follows the master. 

```csharp
var conn = ConnectionMultiplexer.Connect("localhost,serviceName=mymaster");
var db = conn.GetDatabase();
db.StringSet("key", "value");
```
@NickCraver
Copy link
Collaborator

This was fixed in #1431, closing out to cleanup!

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

No branches or pull requests

2 participants