Skip to content

Commit

Permalink
fix problems of code review
Browse files Browse the repository at this point in the history
  • Loading branch information
ING-XIAOJIAN authored Jan 11, 2024
1 parent 4e37f81 commit adc8893
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2174,30 +2174,27 @@ def _send_cluster_commands(
for n in node_commands:
n.read()
finally:
# release all of the redis connections we allocated earlier
# back into the connection pool.
# we used to do this step as part of a try/finally block,
# but it is really dangerous to
# release connections back into the pool if for some
# reason the socket has data still left in it
# from a previous operation. The write and
# read operations already have try/catch around them for
# all known types of errors including connection
# and socket level errors.
# So if we hit an exception, something really bad
# happened and putting any oF
# these connections back into the pool is a very bad idea.
# the socket might have unread buffer still sitting in it,
# and then the next time we read from it we pass the
# buffered result back from a previous command and
# every single request after to that connection will always get
# a mismatched result.
for n in nodes.values():
n.connection_pool.release(n.connection)

# release all of the redis connections we allocated earlier
# back into the connection pool.
# we used to do this step as part of a try/finally block,
# but it is really dangerous to
# release connections back into the pool if for some
# reason the socket has data still left in it
# from a previous operation. The write and
# read operations already have try/catch around them for
# all known types of errors including connection
# and socket level errors.
# So if we hit an exception, something really bad
# happened and putting any oF
# these connections back into the pool is a very bad idea.
# the socket might have unread buffer still sitting in it,
# and then the next time we read from it we pass the
# buffered result back from a previous command and
# every single request after to that connection will always get
# a mismatched result.
# for n in nodes.values():
# n.connection_pool.release(n.connection)

# if the response isn't an exception it is a
# valid response from the node
# we're all done with that command, YAY!
Expand Down

0 comments on commit adc8893

Please sign in to comment.