private boolean isTxnsOpenAndNotReadOnly(MultiDataSourceJdbcResource jdbcResource, List<Long> txnIds) {
    List<String> queries = new ArrayList<>();
    StringBuilder prefix = new StringBuilder();

    // Get the count of txns from the given list that are in open state and not read-only.
    // If the returned count is same as the input number of txns, then all txns are in open state and not read-only.
    prefix.append("SELECT COUNT(*) FROM \"TXNS\" WHERE \"TXN_STATE\" = ").append(TxnStatus.OPEN)
        .append(" AND \"TXN_TYPE\" != ").append(TxnType.READ_ONLY.getValue()).append(" AND ");

    TxnUtils.buildQueryWithINClause(jdbcResource.getConf(), queries, prefix, new StringBuilder(),
        txnIds, "\"TXN_ID\"", false, false);

    AtomicLong count = new AtomicLong(0);
    for (String query : queries) {
      LOG.debug("Going to execute query <{}>", query);
      jdbcResource.getJdbcTemplate().query(query, rs -> {
        while (rs.next()) {
          count.set(count.get() + rs.getLong(1));
        }
        return null;
      });
    }
    return count.get() == txnIds.size();
  }
Checks if all the txns in the list are in open state and not read-only.
@param txnIds list of txns to be evaluated for open state/read-only status
@return If all the txns in open state and not read-only, then return true else false
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/jdbc/functions/AllocateTableWriteIdsFunction.java