@SuppressWarnings("squid:S2445")
  public synchronized long tryCancel(ListenableFuture<Void> future) {
    Validate.notNull(future, "The future to be cancelled can not be null.");
    // add synchronized on the future to avoid that the future is concurrently completed by
    // MemoryPool.free() which may lead to memory leak.
    synchronized (future) {
      // If the future is not a MemoryReservationFuture, it must have been completed.
      if (future.isDone()) {
        return 0L;
      }
      Validate.isTrue(
          future instanceof MemoryReservationFuture,
          "invalid future type " + future.getClass().getSimpleName());
      future.cancel(true);
    }
    return ((MemoryReservationFuture<Void>) future).getBytesToReserve();
  }
Cancel the specified memory reservation. If the reservation has finished, do nothing.

@param future The future returned from {@link #reserve(String, String, String, long, long)}
@return If the future has not complete, return the number of bytes being reserved. Otherwise,
    return 0.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/memory/MemoryPool.java