RedisLabs / redis-cluster-proxy

A proxy for Redis clusters.
GNU Affero General Public License v3.0
993 stars 132 forks source link

Question about idempotent #6

Closed shenlongxing closed 4 years ago

shenlongxing commented 5 years ago

I have read the source code of redis cluster proxy. And as far as I am concerned, there may be situations that idempotent is not guaranted. The proxy uses threads pool (default 8) to receive and dispatch commands and since thread is chosen by round robin, the commands may not be executed in the exactly same order as the client sent due to threads connection error or something alike.

artix75 commented 5 years ago

Every client is assigned to a single thread, so every command from a specific client is always dispatched to the cluster by the same thread, and since the connection to a single node of the cluster is thread-specific there should be no issues. Furthermore, since by default every thread dispatches its queries in a multiplexed context (they come from different clients), the order of the replies is guaranteed by their internal ID that is handled by a radix tree. In every test I've made I've never had issues related to commands order. I hope I've matched your concerns, anyway feel free to tell me your impressions about what you consider weak. Thank you.

antirez commented 4 years ago

@shenlongxing I wonder if Fabio's reply is satisfying for you, the fact that the thread is sticky from the POV of the client, and the ID system in the radix tree that orders everything. If it's ok we can close this one.

shenlongxing commented 4 years ago

@artix75 @antirez Thanks for the reply, it is ok to me.