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
connectRetry doesn't work if the server comes up after the first attempt has failed #373
Comments
FWIW, after increasing connectRetry up to 20 and leaving connectTimeout as its default of 5 seconds, I can see a 4-attempt pattern to the failures In the cycle, the first attempt gets IsFaulted with UnableToResolvePhysicalConnection, the second gets IsFaulted with ConnectionDisposed, then the next 2 get IsCanceled
If I increase the timeout from 5 seconds to 10 seconds the 'did not respond' only happens once per cycle (so it becomes a 3-attempt cycle), but otherwise it stays the same AFAICT. If I increase the timeout up to 30 seconds, then the 'did not respond' ones don't happen, but instead seem to turn into faulted: with UnableToConnect, although there's a Disposed near the beginning. Same pattern happens at 60 seconds as well.
|
I have a workaround: if setting configuration in code: The relevant bit is (I think) here, although it's more a guess than anything at this point. StackExchange.Redis/StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs Lines 1245 to 1252 in c4b9fc3
Since the configuration doesn't explicitly set it, the TieBreaker configuration is set (specifically, to __Booksleeve_TieBreak, but the actual value doesn't matter, just that it's set). So, even though I'm connecting to just a single stand-alone server, useTiebreakers ends up being true. StackExchange.Redis/StackExchange.Redis/StackExchange/Redis/ConnectionMultiplexer.cs Line 1207 in c4b9fc3
Should useTiebreakers require both the key being set and endpoints.Count > 1? In any case, I have a workaround, and the test passes when the workaround is added. |
That's not going to fix many other cases...but it's still probably a good idea. Less complication in simpler scenarios is always a good thing - thoughts @mgravell? |
@NickCraver probably not worth filing separately, but FWIW since the ConfigurationOptions.ToString only adds an option if its set, then setting tieBreaker to empty string (which isn't its default value) currently doesn't round-trip since it won't be serialized in the string. |
This was fixed in the 2.x rewrite - just cleaning up older issues :) |
If the target redis server is down ('connection refused' error coming back from socket attempts) when the first attempt happens, if the server comes up, the later retries still fail such that the overall connect still fails (after it exhausts the retry limit).
Here's a failing test I added locally to show the issue. I'm not sure if there's an existing/canonical way to do this, but if this is fine, I can make a pull request with it if that's helpful.
Log from connect attempt:
The text was updated successfully, but these errors were encountered: