There is actually a reason why we fetch the partition state directly from 
partitionStates here again under the partitionMapLock. partitionStates can be 
modified after we release the lock in doWork() (e.g, due to a leadership 
change). When we get to processFetchRequest(),  a replica may have become the 
leader and therefore have been removed from partitionStates. In this case, we 
don't want to append the pending fetched data to the log since this partition 
could have appended new data from the producer to the log. This may cause 
leader epoch to be out of order in the log.

[ Full content available at: https://github.com/apache/kafka/pull/5587 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to