[ 
https://issues.apache.org/jira/browse/KAFKA-13778?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

zhaobo updated KAFKA-13778:
---------------------------
    Description: 
The design purpose of the code is that only the leader broker can determine the 
preferred read-replica.

 
{code:java}

// If we are the leader, determine the preferred read-replica val 
preferredReadReplica = clientMetadata.flatMap( metadata => 
findPreferredReadReplica(partition, metadata, replicaId, fetchInfo.fetchOffset, 
fetchTimeMs)) 
{code}
 

But in fact, since the broker does not judge whether it is the leader or not, 
the follower will also execute the preferred read-replica selection.
{code:java}


partition.leaderReplicaIdOpt.flatMap { leaderReplicaId =>
  // Don't look up preferred for follower fetches via normal replication and
  if (Request.isValidBrokerId(replicaId))
    None
  else { {code}

  was:
The design purpose of the code is that only the leader broker can determine the 
preferred read-replica.

 
{code:java}
//代码占位符

{code}
 

But in fact, since the broker does not judge whether it is the leader or not, 
the follower will also execute the preferred read-replica selection.
{code:java}
//代码占位符
partition.leaderReplicaIdOpt.flatMap { leaderReplicaId =>
  // Don't look up preferred for follower fetches via normal replication and
  // don't look up preferred read replica while fetch from follower replica
  if (Request.isValidBrokerId(replicaId))
    None
  else { {code}


> Fix follower broker also always execute preferred read-replica selection
> ------------------------------------------------------------------------
>
>                 Key: KAFKA-13778
>                 URL: https://issues.apache.org/jira/browse/KAFKA-13778
>             Project: Kafka
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.0
>            Reporter: zhaobo
>            Assignee: zhaobo
>            Priority: Minor
>
> The design purpose of the code is that only the leader broker can determine 
> the preferred read-replica.
>  
> {code:java}
> // If we are the leader, determine the preferred read-replica val 
> preferredReadReplica = clientMetadata.flatMap( metadata => 
> findPreferredReadReplica(partition, metadata, replicaId, 
> fetchInfo.fetchOffset, fetchTimeMs)) 
> {code}
>  
> But in fact, since the broker does not judge whether it is the leader or not, 
> the follower will also execute the preferred read-replica selection.
> {code:java}
> partition.leaderReplicaIdOpt.flatMap { leaderReplicaId =>
>   // Don't look up preferred for follower fetches via normal replication and
>   if (Request.isValidBrokerId(replicaId))
>     None
>   else { {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to