private void waitTillRefCountZero() throws InterruptedException {
    if (isActive) {
      long singleWaitMs = Math.min(500, WAIT_TIME_FOR_CLEANUP_MS);
      long waitSoFar = 0;
      List<LogSegmentName> segmentsUnderCompaction =
          compactionLog.getCompactionDetails().getLogSegmentsUnderCompaction();
      for (LogSegmentName segmentName : segmentsUnderCompaction) {
        while (srcLog.getSegment(segmentName).refCount() > 0 && waitSoFar < WAIT_TIME_FOR_CLEANUP_MS) {
          time.sleep(singleWaitMs);
          waitSoFar += singleWaitMs;
        }
        if (srcLog.getSegment(segmentName).refCount() > 0) {
          logger.debug("Ref count of {} in {} did not go down to 0", segmentName, storeId);
        }
      }
    }
  }
Waits until the ref counts of the all the log segments that need to be cleaned up reach 0.
@throws InterruptedException if the wait is interrupted.
ambry-store/src/main/java/com/github/ambry/store/BlobStoreCompactor.java