@lindong28 Thanks for the comment. You brought up a very good point. We need to differentiate between events that need to be processed by the active controller and events that need to be processed by every broker. Because `ControllerMovedException` only indicates active controller role switched, we shouldn't try to stop processing events in the latter category.
>From the implementation point of view, we can just mark the controller as >inactive and resign without touching the event queue at all instead of doing a >conditional clear operation on the queue. The reason why we want to clear the >queue before is that if controller has moved, we don't want the event thread >to waste cycles on unnecessary events and want it to get to `Reelect` as soon >as possible by clearing the potential backlog. Since we already have logic >like `if (!isActive) return` to guard against events related to active >controller, we just need to preempt the "mark inactive and resign" operation >when `ControllerMovedException` happens. This will ensure correctness as well >as simplicity and resolve the event queue backlog with small overhead (most >cases we just dequeue controller event and do a boolean check) [ Full content available at: https://github.com/apache/kafka/pull/5101 ] This message was relayed via gitbox.apache.org for [email protected]
