apache/beam · warning

Postgres reads require disableAutoCommit to be true, overrid

Error message

Postgres reads require disableAutoCommit to be true, overriding to true.

What it means

Warning logged by the Postgres read provider when disableAutoCommit is explicitly set to false. Postgres JDBC reads in Beam require auto-commit disabled for consistent OFFSET/range partitioning, so the provider overrides the value to true (and also clears connectionInitSql). The pipeline proceeds with corrected settings.

Source

Thrown at sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/providers/ReadFromPostgresSchemaTransformProvider.java:78

    String jdbcType = configuration.getJdbcType();
    if (jdbcType != null && !jdbcType.isEmpty() && !jdbcType.equals(jdbcType())) {
      LOG.warn(
          "Wrong JDBC type. Expected '{}' but got '{}'. Overriding with '{}'.",
          jdbcType(),
          jdbcType,
          jdbcType());
      configuration = configuration.toBuilder().setJdbcType(jdbcType()).build();
    }

    List<@org.checkerframework.checker.nullness.qual.Nullable String> connectionInitSql =
        configuration.getConnectionInitSql();
    if (connectionInitSql != null && !connectionInitSql.isEmpty()) {
      throw new IllegalArgumentException("Postgres does not support connectionInitSql.");
    }

    Boolean disableAutoCommit = configuration.getDisableAutoCommit();
    if (disableAutoCommit != null && !disableAutoCommit) {
      LOG.warn("Postgres reads require disableAutoCommit to be true, overriding to true.");
    }

    // Override "connectionInitSql" and "disableAutoCommit" for postgres
    configuration =
        configuration.toBuilder()
            .setConnectionInitSql(Collections.emptyList())
            .setDisableAutoCommit(true)
            .build();
    return new PostgresReadSchemaTransform(configuration);
  }

  public static class PostgresReadSchemaTransform extends JdbcReadSchemaTransform {
    public PostgresReadSchemaTransform(JdbcReadSchemaTransformConfiguration config) {
      super(config, POSTGRES);
    }
  }
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Remove the setDisableAutoCommit(false) call so the Postgres default (true) applies.
  2. Set setDisableAutoCommit(true) explicitly in the configuration.
  3. Also remove connectionInitSql for Postgres reads, since Postgres does not support it (an IllegalArgumentException otherwise).
  4. If auto-commit cannot be disabled, use a different database provider that supports it.

Example fix

// before
JdbcReadSchemaTransformConfiguration cfg = base.toBuilder()
    .setDisableAutoCommit(false)
    .build();
// after
JdbcReadSchemaTransformConfiguration cfg = base.toBuilder()
    .setDisableAutoCommit(true)
    .build();
Defensive patterns

Strategy: validation

Validate before calling

if (Boolean.FALSE.equals(config.getDisableAutoCommit())) {
  config = config.toBuilder().setDisableAutoCommit(true).build(); // required for Postgres
}
if (config.getConnectionInitSql() != null && !config.getConnectionInitSql().isEmpty()) {
  throw new IllegalArgumentException("connectionInitSql is unsupported for Postgres");
}

Prevention

When it happens

Trigger: Calling from() on ReadFromPostgresSchemaTransformProvider with a JdbcReadSchemaTransformConfiguration where setDisableAutoCommit(false) was called and connectionInitSql is null or empty.

Common situations: Sharing one configuration builder between MySQL/SQL Server reads (where auto-commit may be allowed) and Postgres reads; porting an existing MySQL read config to Postgres.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/cb5153c789b82b11. Report an issue: GitHub.