Synchronization issues in Redis-QUIC #1097
-
Hey! We are doing a project where we are changing the cluster bus communication of Redis from TCP to QUIC using msquic (https://redis.io/topics/cluster-tutorial). We are running into some synchronization issues as now Redis has become multi-threaded. We have documented the problem and some solutions (which has their own problems). Looking for some leads/direction on how we could solve it. Any help is greatly appreciated. Problem and Context: Possible Solutions and their Problems:
Can you please suggest some other ideas which will be useful in solving this problem? Also, is there any way we could get away without locking (some other synchronization pattern we could employ?). Any help in this regard is greatly appreciated. If something is not clear, please let us know. We could provide more details to clarify. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Synchronization is hard! Whenever you have multiple threads sharing a resource (a connection) you're going to have to add some synchronization. Also, I'd strongly recommend staying away from any global mutex/lock design. As you already mentioned, if you have a lot of parallel threads trying to use it, you're going to have problems. Generally, the goal should be to have a lock specific to the smallest resource possible. This might be a whole connection. It might be for a "work queue" on a connection. When you have a shared object with multiple users of it, having a reference count on the object can also be a good idea. When a new user of the object comes along, you increment the ref count. When one goes away, you decrement it. When it goes to zero, you clean up. As to exactly how you should do things in your scenario, I'd probably need some more details on exactly what types of operations are being performed on which threads, but without that extra info, I'd recommend something like this:
Bottom line, though, there are lots of ways to go about this. Feel free to provide more details and I can try to give you a better suggestion. |
Beta Was this translation helpful? Give feedback.
Synchronization is hard! Whenever you have multiple threads sharing a resource (a connection) you're going to have to add some synchronization. Also, I'd strongly recommend staying away from any global mutex/lock design. As you already mentioned, if you have a lot of parallel threads trying to use it, you're going to have problems. Generally, the goal should be to have a lock specific to the smallest resource possible. This might be a whole connection. It might be for a "work queue" on a connection. When you have a shared object with multiple users of it, having a reference count on the object can also be a good idea. When a new user of the object comes along, you increment the ref count.…