antirez/redis — pull request #1253 by yossigo (2013-08-21 08:30:59+00:00)
Title: Prevent (some) race conditions between connections.

Apparently there are quite situations in the test suite where different connections race each other. In a regular "make test" it probably never shows up, but once we leverage (portions of) the test suite and use remote servers things come up.

Not sure it's such a high priority to fix but here are few recent fixes we had to do and some clarifications:
In pubsub.tcl:
1. Consecutive pubsub tests using the same channels may fail, as the socket disconnection of a previous test may not be complete and thus the server may still count it as a live subscription.
2. UNSUBSCRIBE on a deferring client races and may lose to commands that execute on the main connection.

In list.tcl:
There is an inherent race between the DEL, BRPOPLPUSH and LRANGE. Unfortunately, there's no easy way to tell BRPOPLPUSH was received (unless we look at INFO - too complex), but the PING in the beginning reduces the chances significantly as we can at least be sure the 3 connections are established when the race starts.