mperham/connection_pool — pull request #34 by walkeriniraq (2013-08-15 01:30:44+00:00)
Title: Connection Pool is per-thread

I encapsulated the problem I've got into this gist:

http://gist.github.com/walkeriniraq/6237127

Basically, a redis connection is stateful, in that it "remembers" whether or not it's in a pipeline call. When it's in a pipeline, the return values are promises instead of actual database values. Since the connection pool shares a single connection across the entire thread, it can lead to some surprising behavior.

It doesn't seem like SQL connections have this problem as the connection itself is not stateful - i.e. starting a transaction on a SQL connection doesn't stop the connection from making other calls.

I've "solved" the problem in my own branch by returning a new connection for every request to the connection pool, but that breaks the current "nested" checkout tests (as it does exactly the opposite of what they're supposed to test).

The only other thing I can think of is to add an option to the initializer. I'm open to better ideas though.