private void releaseTVListOwnedByQuery() {
    for (TVList tvList : tvListSet) {
      tvList.lockQueryList();
      Set<QueryContext> queryContextSet = tvList.getQueryContextSet();
      try {
        queryContextSet.remove(this);
        if (tvList.getOwnerQuery() == this) {
          if (queryContextSet.isEmpty()) {
            LOGGER.debug(
                "TVList {} is released by the query, FragmentInstance Id is {}",
                tvList,
                this.getId());
            memoryReservationManager.releaseMemoryCumulatively(tvList.calculateRamSize());
            tvList.clear();
          } else {
            FragmentInstanceContext queryContext =
                (FragmentInstanceContext) queryContextSet.iterator().next();
            LOGGER.debug(
                "TVList {} is now owned by another query, FragmentInstance Id is {}",
                tvList,
                queryContext.getId());
            tvList.setOwnerQuery(queryContext);
          }
        }
      } finally {
        tvList.unlockQueryList();
      }
    }
  }
It checks all referenced TVList by the query: 1. If current is not the owner, just remove
itself from query context list 2. If current query is the owner and no other query use it now,
release the TVList 3. If current query is the owner and other queries still use it, set the
next query as owner
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/fragment/FragmentInstanceContext.java