-
Notifications
You must be signed in to change notification settings - Fork 127
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
reader: fix setting max_in_flight to 0 #229
reader: fix setting max_in_flight to 0 #229
Conversation
/cc @mreiferson @ploxiln |
Thanks for submitting this. This is a tricky case ... I'm not sure exactly how setting max_in_flight lower in general works. This might be a good patch in the short term as-is. But I have some more thoughts :) This is what I think are some interesting sections of code: def _send_rdy(self, conn, value):
...
if value and (self.disabled() or self.max_in_flight == 0):
logger.info('[%s:%s] disabled, delaying RDY state change', conn.id, self.name)
# retry later ... elided
return
if value > conn.max_rdy_count:
value = conn.max_rdy_count
new_rdy = max(self.total_rdy - conn.rdy + value, 0)
if new_rdy > self.max_in_flight:
return
if conn.send_rdy(value):
self.total_rdy = new_rdy
def set_max_in_flight(self, max_in_flight):
self.max_in_flight = max_in_flight
if max_in_flight == 0:
# set RDY 0 to all connections
for conn in itervalues(self.conns):
if conn.rdy > 0:
logger.debug('[%s:%s] rdy: %d -> 0', conn.id, self.name, conn.rdy)
self._send_rdy(conn, 0)
self.total_rdy = 0
else:
self.need_rdy_redistributed = True
self._redistribute_rdy_state() Note that, if there is just one connection, this does work as intended: new_rdy = max(self.total_rdy - conn.rdy + value, 0)
if new_rdy > self.max_in_flight:
return
But, if there are multiple connections ... then The normal non-zero case goes through |
Yes. It is.
I am not quite sure about this logic. :) So i only add the bypass logic for the special case where
Actually i am not quite sure about this. So in order to not influence other logic, i only added the special case where |
I am also not quite sure about the deterministic transfer logic. It is quite complicated. If you are sure that when |
I haven't dug into this yet, but I'm curious what @alpaker thinks, who's touched some of this code most recently. |
I think this:
can be removed entirely, since any protection it supplies is superfluous. If a call to |
And (I'm pretty sure) nothing in the reader currently relies on that part of |
I'm sold, thanks. |
PR for this alternative fix: #230 |
thanks @alpaker and thanks for raising the issue @andyxning! |
Currently, when we set max_in_flight to 0 to disable consuming by
set_in_max_flight
, it is not working as expected.As we need, when we set max_in_flight to 0, the return value of
in
_send_rdy
is a positive number. Thus the if clausewill be always true, as currently the value for
self.max_in_flight
is 0.Thus the
_send_rdy
will shortly return and the new 0 rdy will not be set.