MEDIARITHMICS / liquibase-clickhouse

Apache License 2.0
43 stars 39 forks source link

clickhouse-jdbc and liquibase-clickhouse --> Transactions are not supported #11

Closed DimiF4W closed 2 years ago

DimiF4W commented 3 years ago

Hi guys,

We have a very basic setup of clickhouse and liquibase-clickhouse but it doenst work with the official Clickhouse Driver. The official driver always gives error:

liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: java.sql.SQLFeatureNotSupportedException: Transactions are not supported
    at liquibase.database.AbstractJdbcDatabase.setAutoCommit(AbstractJdbcDatabase.java:1234)
    at liquibase.changelog.ChangeSet.execute(ChangeSet.java:704)
    at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:49)
    at liquibase.changelog.ChangeLogIterator$2.lambda$null$0(ChangeLogIterator.java:111)
    at liquibase.Scope.lambda$child$0(Scope.java:177)

SpringLiquibase config:

    @Bean(name = CLICKHOUSE_DATASOURCE)
    public DataSource createClickhouseDataSource() {
        ClickHouseProperties properties = new ClickHouseProperties();
        properties.setPassword(yyy);
        properties.setUser(xxx);
       ...
        return new ClickHouseDataSource(zzz, properties);
    }

  @Primary
    @Lazy(false)
    @Bean(name = CLICKHOUSE_LIQUIBASE_BEAN_NAME)
    @DependsOn(CLICKHOUSE_DATASOURCE)
    public SpringLiquibase liquibaseClickhouse(@Qualifier(CLICKHOUSE_DATASOURCE) DataSource dataSource) {
        // Configure custom Clickhouse Liquibase settings
        ...
        DatabaseFactory.getInstance().register(new ClickHouseDatabase());

        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setDataSource(dataSource);
        ....
        return liquibase;
    }

The official connection (ClickHouseConnectionImpl) does the following:

    @Override
    public void setAutoCommit(boolean autoCommit) throws SQLException {
        if (autoCommit) {
            return;
        }
        throw new SQLFeatureNotSupportedException("Transactions are not supported");
    }

I already tried to set runInTransaction="false" inside liquibase xmls but this doesnt change anything.

Version info: clickhouse-jdbc: 0.3.1-patch --> https://github.com/ClickHouse/clickhouse-jdbc clickhouse-liquibase: 0.6.1

igorepim commented 2 years ago

This problem is introduced in the last version of clickhouse-jdbc 0.3.1-patch https://github.com/ClickHouse/clickhouse-jdbc/issues/708 You can try to use clickhouse-jdbc 0.3.1.