-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reusing connections in a transaction state (?) #132
Comments
This certainly seems like a bug in txredisapi. Looks like when you call From a quick glance on the source code, I haven't found any clues. But txredisapi's implementation of transactions is far from ideal, so it is easy to miss something... Do you use |
We use Here is a sample code using
|
I still can't find the bug that makes connection that is currently inside transaction to be available in the pool :( Seems like it somehow gets back to BTW, in this particular code you don't need transaction at all — you may just call BTW 2: pipe = yield redis.pipeline()
pipe.op1(args1)
pipe.op2(args2)
pipe.op3(args3)
results = yield pipe.execute_pipeline() results = yield defer.gatherResults([
redis.op1(args1),
redis.op2(args2),
redis.op3(args3)
]) But using pipe = redis.pipeline()
pipe.op1(args1)
yield treq.get("http://...") # ← the connection to redis will not be available to another code while request is in progress
pipe.op2(args2)
yield redis.execute_pipeline() My strong opinion is that pipelines should not have been implemented in txredisapi at all. I think this is the result of misconception about how async network calls is different from sync ones :) |
Thank you very much for your effort and time. I will look into this further. Regarding you comments about pipelining. I have a different opinion although not as educated as yours. Reading this https://redis.io/topics/pipelining specifically where it says:
I see benefit in grouping commands (in some cases) in that way due to the reduced RTT. It is also stated below. I do not know how this library is implemented. Is it using something this like this ? How is pipelining implement in this library ? Thank you again for you time |
Since txredisapi is based on Twisted that is all about asynchrony, you may choose yourself whether you want to stop and wait for the end of operation or want to do something else while it is in progress. If you do: redis.set('a', 1)
redis.set('b', 2)
redis.set('c', 3) then all three commands will be actually sent simultaneously, without waiting for each other's responses. When interpeter hits But if you actually want to wait for the previous operation result before sending the next one, Twisted gives you the very convenient @inlineCallbacks
def f():
yield redis.set('a', 1)
yield redis.set('b', 2)
So, pipelining Redis requests is fantastic thing and one will only receive a little fraction of Redis performance without it. But with Twisted you can receive pipelining for free without special support from txredisapi, just by not waiting on responses of previous commands before sending next ones. |
Good morning,
I am using:
PyPy 5.10.0
txredisapi 1.4.4
Twisted 17.5.0
When under load (lots of redis traffic) there are occasions where, when doing a burst of SCANs to get a list of keys from Redis, instead of getting back cursor information and data, we get the string "QUEUED". From what I understand so far the string "QUEUED" is a reply from Redis when I am issuing commands into a transaction. I am using transactions to periodically update a group of Redis keys asynchronously.
We are using makeUnixConnection() with a pool size of 20.
Here is how I am doing SCANs:
And here is a sample print out of the error occurring:
Can anyone help to shed some light onto this issue ?
The text was updated successfully, but these errors were encountered: