long generateTailKey() {
    long key = eventSeqNum.addAndGet(partitionedRegion.getTotalNumberOfBuckets());
    if (key < 0 || key % getPartitionedRegion().getTotalNumberOfBuckets() != getId()) {
      logger.error("ERROR! The sequence number {} generated for the bucket {} is incorrect.",
          new Object[] {key, getId()});
    }
    if (logger.isDebugEnabled()) {
      logger.debug("WAN: On primary bucket {}, setting the seq number as {}", getId(),
          eventSeqNum.get());
    }
    return eventSeqNum.get();
  }
Keep checking if CM has contained any key in keys. If yes, wait for notify, then retry again.
This method will block current thread for long time. It only exits when current thread
successfully save its keys into CM.
geode-core/src/main/java/org/apache/geode/internal/cache/BucketRegion.java