Code review comment: This should be in a `Teardown` method - we can fail at various points above and then the table won't be deleted.

Code under review:
public void testWriteWithBackoff() throws Exception {
    String tableName = DatabaseTestHelper.getTestTableName("UT_WRITE_BACKOFF");
    DatabaseTestHelper.createTable(dataSource, tableName);

    
    Connection connection = dataSource.getConnection();
    Statement lockStatement = connection.createStatement();
    lockStatement.execute("ALTER TABLE " + tableName + " LOCKSIZE TABLE");
    lockStatement.execute("LOCK TABLE " + tableName + " IN EXCLUSIVE MODE");

    
    connection.setAutoCommit(false);
    PreparedStatement insertStatement =
        connection.prepareStatement("insert into " + tableName + " values(?, ?)");
    insertStatement.setInt(1, 1);
    insertStatement.setString(2, "TEST");
    insertStatement.execute();

    
    pipeline
        .apply(Create.of(Collections.singletonList(KV.of(1, "TEST"))))
        .apply(
            JdbcIO.<KV<Integer, String>>write()
                .withDataSourceConfiguration(
                    JdbcIO.DataSourceConfiguration.create(
                        "org.apache.derby.jdbc.ClientDriver",
                        "jdbc:derby:
                .withStatement(String.format("insert into %s values(?, ?)", tableName))
                .withPreparedStatementSetter(
                    (element, statement) -> {
                      statement.setInt(1, element.getKey());
                      statement.setString(2, element.getValue());
                    }));

    
    Thread commitThread = new Thread(() -> {
      try {
        Thread.sleep(10000);
        connection.commit();
      } catch (Exception e) {
        
      }
    });
    commitThread.start();
    pipeline.run();
    commitThread.join();

    try (Connection readConnection = dataSource.getConnection()) {
      try (Statement statement = readConnection.createStatement()) {
        try (ResultSet resultSet = statement.executeQuery("select count(*) from "
            + tableName)) {
          resultSet.next();
          int count = resultSet.getInt(1);
          
          
          Assert.assertEquals(2, count);
        }
      }
    } finally {
      DatabaseTestHelper.deleteTable(dataSource, tableName);
    }

  }

Line commented on: DatabaseTestHelper.deleteTable(dataSource, tableName);

Revised code:
public void testWriteWithBackoff() throws Exception {
    String tableName = DatabaseTestHelper.getTestTableName("UT_WRITE_BACKOFF");
    DatabaseTestHelper.createTable(dataSource, tableName);

    
    Connection connection = dataSource.getConnection();
    Statement lockStatement = connection.createStatement();
    lockStatement.execute("ALTER TABLE " + tableName + " LOCKSIZE TABLE");
    lockStatement.execute("LOCK TABLE " + tableName + " IN EXCLUSIVE MODE");

    
    connection.setAutoCommit(false);
    PreparedStatement insertStatement =
        connection.prepareStatement("insert into " + tableName + " values(?, ?)");
    insertStatement.setInt(1, 1);
    insertStatement.setString(2, "TEST");
    insertStatement.execute();

    
    pipeline
        .apply(Create.of(Collections.singletonList(KV.of(1, "TEST"))))
        .apply(
            JdbcIO.<KV<Integer, String>>write()
                .withDataSourceConfiguration(
                    JdbcIO.DataSourceConfiguration.create(
                        "org.apache.derby.jdbc.ClientDriver",
                        "jdbc:derby:
                .withStatement(String.format("insert into %s values(?, ?)", tableName))
                .withRetryStrategy((JdbcIO.RetryStrategy) e -> {
                  return e.getSQLState().equals("XJ208"); 
                })
                .withPreparedStatementSetter(
                    (element, statement) -> {
                      statement.setInt(1, element.getKey());
                      statement.setString(2, element.getValue());
                    }));

    
    Thread commitThread = new Thread(() -> {
      try {
        Thread.sleep(10000);
        connection.commit();
      } catch (Exception e) {
        
      }
    });
    commitThread.start();
    pipeline.run();
    commitThread.join();

    
    expectedLogs.verifyWarn("Deadlock detected, retrying");

    try (Connection readConnection = dataSource.getConnection()) {
      try (Statement statement = readConnection.createStatement()) {
        try (ResultSet resultSet = statement.executeQuery("select count(*) from "
            + tableName)) {
          resultSet.next();
          int count = resultSet.getInt(1);
          
          
          Assert.assertEquals(2, count);
        }
      }
    }

  }