redis-py icon indicating copy to clipboard operation
redis-py copied to clipboard

Dev/no lock

Open kristjanvalur opened this issue 3 years ago • 2 comments

Pull Request check-list

Please make sure to review and check all of these items:

  • [x] Does $ tox pass with this change (including linting)?
  • [x] Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • [x] Is the new or changed code fully tested?
  • [ ] Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • [ ] Is there an example added to the examples folder (if applicable)?
  • [ ] Was the change added to CHANGES file?

NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.

Description of change

An asyncio.Lock present around the redis.asyncio.Connection._parser.read_response() is removed. This is not required, since only a single task should be sending/receiving on a single Connection at the same time. There is no lock around the send() code and Without a lock around the entire execute_command() (send, and receive) there has been no guarantee that a response is returned which matches the sent command, if more than one task are sending.

A single unittest for concurrent execution was skipped to not run in single-connection mode. This unittest would have also sporadically failed before this PR if the concurrent commands were different. As it happened, all 10 were the exact same ping command and so mismatching requests/responses were never detected.

kristjanvalur avatar Jul 27 '22 13:07 kristjanvalur

Codecov Report

Merging #2308 (b5ebada) into master (b5ebada) will not change coverage. The diff coverage is n/a.

:exclamation: Current head b5ebada differs from pull request most recent head 8d86e87. Consider uploading reports for the commit 8d86e87 to get more accurate results

@@           Coverage Diff           @@
##           master    #2308   +/-   ##
=======================================
  Coverage   92.21%   92.21%           
=======================================
  Files         111      111           
  Lines       28781    28781           
=======================================
  Hits        26539    26539           
  Misses       2242     2242           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Jul 27 '22 13:07 codecov-commenter

As usual, sporadic CI failures with docker.

kristjanvalur avatar Jul 29 '22 07:07 kristjanvalur

This PR, if accepted, will impact #2295 and make it simpler.

kristjanvalur avatar Aug 22 '22 13:08 kristjanvalur

🍾

kristjanvalur avatar Sep 28 '22 18:09 kristjanvalur