@SuppressWarnings("squid:S1181")
  private Throwable closeAndDestroyOperators() {
    // record the current interrupted status (and clear the flag); we'll reset it later
    boolean wasInterrupted = Thread.interrupted();

    Throwable inFlightException = null;

    try {
      root.close();

      if (driverContext.mayHaveTmpFile()) {
        cleanTmpFile();
      }

      sink.setNoMoreTsBlocks();

      Map<String, long[]> operatorType2TotalCost = new HashMap<>();
      // record operator execution statistics to metrics
      List<OperatorContext> operatorContexts = driverContext.getOperatorContexts();
      for (OperatorContext operatorContext : operatorContexts) {
        String operatorType = operatorContext.getOperatorType();
        long[] value = operatorType2TotalCost.computeIfAbsent(operatorType, k -> new long[2]);
        value[0] += operatorContext.getTotalExecutionTimeInNanos();
        value[1] += operatorContext.getNextCalledCount();
      }
      for (Map.Entry<String, long[]> entry : operatorType2TotalCost.entrySet()) {
        QUERY_METRICS.recordOperatorExecutionCost(entry.getKey(), entry.getValue()[0]);
        QUERY_METRICS.recordOperatorExecutionCount(entry.getKey(), entry.getValue()[1]);
      }

    } catch (InterruptedException t) {
      // don't record the stack
      wasInterrupted = true;
    } catch (Throwable t) {
      inFlightException =
          addSuppressedException(
              inFlightException,
              t,
              "Error closing operator {} for driver task {}",
              root.getOperatorContext().getOperatorId(),
              driverContext.getDriverTaskID());
    } finally {
      // reset the interrupted flag
      if (wasInterrupted) {
        Thread.currentThread().interrupt();
      }
    }
    return inFlightException;
  }
Try to acquire the {@code exclusiveLock} with {@code timeout} and run a {@code task}. If the
{@code interruptOnClose} flag is set to {@code true} the {@code task} will be interrupted if
the {@code Driver} is closed.

<p>Note: task cannot return null
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/driver/Driver.java