private void runTransactions()

in benchmarks/tpcc/src/main/java/com/google/cloud/pgadapter/tpcc/AbstractBenchmarkRunner.java [90:136]


  private void runTransactions() throws SQLException, InterruptedException {
    while (!Thread.interrupted()) {
      try {
        int transaction = random.nextInt(23);
        if (transaction < 10) {
          newOrder();
          statistics.incNewOrder();
        } else if (transaction < 20) {
          payment();
          statistics.incPayment();
        } else if (transaction < 21) {
          orderStatus();
          statistics.incOrderStatus();
        } else if (transaction < 22) {
          delivery();
          statistics.incDelivery();
        } else if (transaction < 23) {
          stockLevel();
          statistics.incStockLevel();
        } else {
          LOG.info("No transaction");
        }
      } catch (Throwable exception) {
        if ((exception instanceof PSQLException psqlException)
            && psqlException.getServerErrorMessage() != null
            && Objects.equals(
                psqlException.getServerErrorMessage().getSQLState(),
                PSQLState.SERIALIZATION_FAILURE.getState())
            && Objects.requireNonNull(psqlException.getServerErrorMessage().getMessage())
                .contains("concurrent modification")) {
          LOG.debug("Transaction aborted by Cloud Spanner via PG JDBC");
          statistics.incAborted();
        } else if (exception instanceof JdbcAbortedException) {
          LOG.debug("Transaction aborted by Cloud Spanner via Spanner JDBC");
          statistics.incAborted();
        } else {
          LOG.warn("Transaction failed", exception);
          statistics.incFailed();
        }
        try {
          executeStatement("rollback");
        } catch (Throwable rollbackException) {
          // Ignore errors. For an interrupted error, the while loop will be ended.
        }
      }
    }
  }