kkonstantine commented on PR #10367:
URL: https://github.com/apache/kafka/pull/10367#issuecomment-1098324150

   Thanks for working on this fix @showuon. Apologies for taking me so long to 
return here. 
   
   My main concern is related to the proposed change to apply consecutive 
rebalances that will perform revocations. 
   
   The current incremental cooperative rebalancing algorithm, is using two 
consecutive rebalances in order to move tasks between workers. One rebalance 
during which revocations are happening and one during which the revoked tasks 
are reassigned. Although clearly this is not an atomic process (as this issue 
also demonstrates) I find that it's a good property to maintain and reason 
about. 
   
   Allowing for consecutive revocations that happen immediately when an 
imbalance is detected might mean that the workers overreact to external 
circumstances that have caused an imbalanced between the initial calculation of 
task assignments of the revocation rebalance and the subsequent rebalance for 
the assignment of revoked tasks. Such circumstances might have to do with 
rolling upgrades, scaling a cluster up or down or simply might be caused by 
temporary instability. We were first able to reproduce this issue in 
integration tests by the test that is currently disabled. 
   
   My main thought was that, instead of risking shuffling tasks too 
aggressively within a short period of time and open the door to bugs that will 
make workers oscillate between imbalanced task assignments continuously and in 
a tight loop, we could use the existing mechanism of scheduling delayed 
rebalances to program workers to perform a pair of rebalanced (revocation + 
reassignment) soon after an imbalance is detected. Regarding when an imbalance 
is detected, the good news is that the leader worker sending the assignment 
during the second rebalance of a pair of rebalances knows that it will send an 
imbalanced assignment (there's no code to detect right now that but can be 
easily added just before the assignment is sent). The idea here would be to 
send this assignment anyways, but also schedule a follow up rebalance that will 
have the opportunity to balance tasks soon with our standard pair of rebalances 
that works dependably as long as no new workers are added or removed between th
 e two rebalances. We can discuss what is a good setting for the delay. One 
obvious possibility is to reuse the existing property. Adding another config 
just for that seems unwarranted. To shield ourselves from infinite such 
rebalances the leader should also keep track of how many such attempts have 
been made and stop attempting to balance out tasks after a certain number of 
tries. Of course every other normal rebalance should reset both this counter 
and possibly the delay. 
   
   I'd be interested to hear what do you think of this approach that is quite 
similar to what you have demonstrated already but potentially less risky in 
terms of changes in the assignor logic and how aggressively the leader attempts 
to fix an imbalance. 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to