-
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
Synchronous events are delivered asynchronously #31
Comments
Yes, that is correct. The intent is to avoid blocking the IO threads. So yes, it is correct as written. Can you provide more information about the scenario that you feel is On 30 April 2014 15:43, paveliak [email protected] wrote:
Regards, Marc |
Suppose I have two clients that need to coordinate access to some data in Redis. Clients use Redis-based locking to synchronize access (because for some reasons I cannot go with Redis transactions). Let's assume that locking is done by checking whether particular key exists and clients need to execute two operations under lock (as a transaction). Here is the sequence of events:
At the end second operation from the first client collides with operations performed by the second client. Even if I run all operations within the Redis transaction (just to queue them all and fire at once) I still can have issues if restart happened right between the entering the lock and starting transaction. If ConnectionFailed notification was delivered synchronously I could abort transaction in the first client before invoking operation #2 in the restarted Redis instance. |
@paveliak I think I understand your scenario, so let's break it down. This all comes down to dependencies; at a basic level if you're restarting redis in the middle of transactions and you're losing your atomic locking mechanism and there's really no sanely handling that no matter how many safeguards we put in place. If you were using transactions, in the transaction itself you can make sure you own the lock. That'd be the proper point here - as close to the atomicity as possible you want the most assurance of atomic behavior. |
ConnectionMultiplexer may deliver notifications about connection failure (and some other infrastructure errors). In some scenarios it might be important to process these notifications synchronously or client may blindly start working with the different Redis instance (e.g. if crashed server was automatically restarted).
Internally StackExchange tries to deliver "connection failed" synchronously by invoking ConnectionMultiplexer.TryCompleteHandler(,,,. false /* isAsync*/). However it looks like isAsync is not handled correctly inside TryCompleteHandler(). In fact "isAsync == true" does synchronous processing while isAsync == false just returns control to the caller hence triggering asynchronous event processing.
Should it be "if (NOT isAsync)" here?
The text was updated successfully, but these errors were encountered: