hiroeorz/eredis_pool — Issue #1: returning worker to pool too early?
Author: lefant
Created: 2011-10-19 05:39:49+00:00
State: open

Hi,

I was just reading through your code (planning to use poolboy for a connection pool myself), when I noticed something weird in eredis_pool:q/3:

q(PoolName, Command, Timeout) ->
Worker = poolboy:checkout(PoolName),
poolboy:checkin(PoolName, Worker),
Reply = eredis:q(Worker, Command, Timeout),
Reply.

shouldn't the poolboy:checkin.. really happen after the Worker has done its eredis:q... request? like so:

q(PoolName, Command, Timeout) ->
Worker = poolboy:checkout(PoolName),
Reply = eredis:q(Worker, Command, Timeout),
poolboy:checkin(PoolName, Worker),
Reply.

otherwise the worker immediately becomes available to other concurrent clients, even before it is done with the request, no?

I am not really planning to use redis at the moment, so ignore / delete at your leisure, but since I already spotted it, I figured I may as well drop you a note.

Fabian