-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
ArgumentOutOfRangeException when accessing ConnectionMultiplexer log #1108
Comments
My guess here is that there was a delayed operation in a race condition; suggested workaround: var log = new StringWriter();
ConnectionMultiplexer mux = ConnectionMultiplexer.Connect(configurationOptions, log);
string logText;
lock (log) { logText = log.ToString(); }
Trace($"ConnectionMultiplexerCreated: id={m_id}, log={logText}"); |
Thanks @mgravell although I am puzzled how locking on StringWriter object would help here because ConnectionMultiplexer locks on |
Oh, you're right - my bad; I incorrectly remembered what it locked on - I thought it locked on the log. So, er... yeah, that's a fun problem. Let me think on that. |
(for context: from distant memory, I suspect that at one point it did lock on the log instance, and then we hit a problem where someone else was also locking on the log instance, and ... well, bad things) |
I think what I'm going to have to do here is create a proxy to the log object, so that I can wipe it once (inside the lock etc) before leaving |
Sounds good. Meanwhile I will wrap ToString() with try/catch. |
…ter; move the sync to there - allows safe detach from the logging
Hi
I got an
ArgumentOutOfRangeException
exception when calling ToString() for the ConnectionMultiplexer log. From the code it looks like all writes to the TextWriter object are synchronized inside the StackExchange.Redis code so the only thing that comes into my mind is that writes might continue after Connect() method returns and then ToString() method collides with those writes. Does it sound plausible?FWIW we are using v1.2.6.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: chunkLength
at System.Text.StringBuilder.ToString()
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
...
Here is our code:
Thanks,
Pavel
The text was updated successfully, but these errors were encountered: