pyArango icon indicating copy to clipboard operation
pyArango copied to clipboard

When using gevent/greenlets, highly concurrent requests can return incorrect responses

Open bkp-billy opened this issue 7 years ago • 4 comments

When sending multiple concurrent requests through gevent/greenlets, requests from one greenlet can sometimes leak their state into other greenlets. So a request will get the response from a different query.

This may be related to a similar issue, under the same circumstances where a "Bad Status Line" exception is thrown when reading a response. Doing a TCPDump shows that the data coming across the wire is correct, but pyArango seems to drop portions of the incoming stream.

bkp-billy avatar May 08 '17 16:05 bkp-billy

I am not familiar with greenlets, but if all threads are behind the same connection query results might get swaped. You could try having several connections, running each query in a different processes instead of threads or you could implement a way to associate each thread to the right result by having them share a lookup table of results.

tariqdaouda avatar May 09 '17 05:05 tariqdaouda

Meanwhile we found out that one needs to use the gevent based http client in order to make this work. Monkey patching the Aikido-session can do the trick.

dothebart avatar Sep 25 '18 16:09 dothebart

Hi @bkp-billy @tariqdaouda @dothebart , I have fixed it by using a different session for each request and also implemented, fixed connection for concurrent requests through gevent/greenlets Check out the fork at dilipvamsi/pyArango/tree/origin/geevent

Regards, Dilip Vamsi.

dilipvamsi avatar Nov 05 '18 07:11 dilipvamsi

Hi @bkp-billy @tariqdaouda @dothebart , As the request.Session is not thread safe it is better to create a session for each request rather than using the same request which fixes everything.

dilipvamsi avatar Mar 04 '19 08:03 dilipvamsi