protected void basicHandlePrimaryEvent(final GatewaySenderEventImpl gatewayEvent) {
    if (sender.isPrimary()) {
      // no need to do anything if we have become the primary
      return;
    }
    GatewaySenderStats statistics = sender.getStatistics();
    // Get the event from the map
    synchronized (unprocessedEventsLock) {
      // If handleFailover() acquired the lock hence double checking
      if (sender.isPrimary()) {
        // no need to do anything if we have become the primary
        return;
      }
      if (unprocessedEvents == null) {
        return;
      }
      boolean isUpdateVersionStamp =
          gatewayEvent.getOperation().equals(Operation.UPDATE_VERSION_STAMP);
      if (isUpdateVersionStamp) {
        return;
      }
      // now we can safely use the unprocessedEvents field
      EventWrapper ew = unprocessedEvents.remove(gatewayEvent.getEventId());

      if (ew == null) {
        // first time for the event
        if (logger.isTraceEnabled()) {
          logger.trace("{}: fromPrimary event {} : {}->{} added to unprocessed token map",
              sender.getId(), gatewayEvent.getEventId(), gatewayEvent.getKey(),
              gatewayEvent.getValueAsString(true));
        }
        {
          Long mapValue =
              System.currentTimeMillis() + AbstractGatewaySender.TOKEN_TIMEOUT;
          Long oldv = unprocessedTokens.put(gatewayEvent.getEventId(), mapValue);
          if (oldv == null) {
            statistics.incUnprocessedTokensAddedByPrimary();
          }
        }
      } else {
        // already added by secondary (i.e. hub)
        // the secondary
        // gateway has already seen this event, and it can be safely
        // removed (it already was above)
        if (logger.isTraceEnabled()) {
          logger.trace(
              "{}: Primary create/update event {}:{}->{} remove from unprocessed events map",
              sender.getId(), gatewayEvent.getEventId(), gatewayEvent.getKey(),
              gatewayEvent.getValueAsString(true));
        }
        ew.event.release();
        statistics.incUnprocessedEventsRemovedByPrimary();
      }
      reapOld(false);
    }
  }
Just remove the event from the unprocessed events map if it is present. This method added to
fix bug 37603
geode-core/src/main/java/org/apache/geode/internal/cache/wan/serial/SerialGatewaySenderEventProcessor.java