private void refreshMissingStoreMessagesForStandbyReplica(RemoteReplicaInfo remoteReplicaInfo) {

    ExchangeMetadataResponse exchangeMetadataResponse = remoteReplicaInfo.getExchangeMetadataResponse();
    Set<MessageInfo> missingStoreMessages = exchangeMetadataResponse.getMissingStoreMessages();

    if (!missingStoreMessages.isEmpty()) {
      Set<MessageInfo> missingStoreMessagesFoundInStore = new HashSet<>();
      try {
        // construct map of message info -> converted non-null local key
        Map<StoreKey, StoreKey> remoteKeyToLocalKeyMap = exchangeMetadataResponse.remoteKeyToLocalKeyMap;
        Map<MessageInfo, StoreKey> remoteMessageToConvertedKeyNonNull = new HashMap<>();
        for (MessageInfo messageInfo : missingStoreMessages) {
          StoreKey convertedKey = remoteKeyToLocalKeyMap.get(messageInfo.getStoreKey());
          if (convertedKey != null) {
            remoteMessageToConvertedKeyNonNull.put(messageInfo, convertedKey);
          }
        }

        // Find the set of store keys that are still missing in the store
        Set<StoreKey> convertedMissingStoreKeys = remoteReplicaInfo.getLocalStore()
            .findMissingKeys(new ArrayList<>(remoteMessageToConvertedKeyNonNull.values()));

        // Filter the remote messages whose keys are now found in store, i.e. not present in convertedMissingStoreKeys set.
        remoteMessageToConvertedKeyNonNull.forEach((messageInfo, convertedKey) -> {
          if (!convertedMissingStoreKeys.contains(convertedKey)) {
            missingStoreMessagesFoundInStore.add(messageInfo);
          }
        });

        // update the missing store messages being tracked for this replica
        exchangeMetadataResponse.removeMissingStoreMessages(missingStoreMessagesFoundInStore);
      } catch (StoreException e) {
        logger.error(
            "Exception occurred while checking for missing keys in local store for partition {} and Remote replica: {}",
            remoteReplicaInfo.getReplicaId().getPartitionId().toPathString(), remoteReplicaInfo.getReplicaId(), e);
        // reset stored metadata response so that metadata request is sent again for this replica
        remoteReplicaInfo.setExchangeMetadataResponse(new ExchangeMetadataResponse(ServerErrorCode.NoError));
      }
    }
  }
Refreshes missing messages found in the exchange metadata response for the input replica by checking in the local store again.
@param remoteReplicaInfo remote replica information
ambry-replication/src/main/java/com/github/ambry/replication/ReplicaThread.java