Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Batch mode not supported for exasol sink connector #5

Closed
kamrankhan1 opened this issue Aug 28, 2019 · 10 comments
Closed

Batch mode not supported for exasol sink connector #5

kamrankhan1 opened this issue Aug 28, 2019 · 10 comments
Labels
documentation User guides, turorials, specifications source:external Issue was created by or on behalf of someone outside the organization

Comments

@kamrankhan1
Copy link

We have implemented connectors to sync data from MySQL to Exasol. However, we found that the kafka-connect-jdbc exasol does not support batch inserts/updates. If we increase the "batch.size" property to more than 1, we start getting errors. Keeping the batch size to 1 makes the sink connector really slow. Can you please fix this issue

@morazow
Copy link
Contributor

morazow commented Aug 29, 2019

Hello,

Thanks for reporting the issue!

Could you please provide more information on the error?

Please be aware that the batch.size parameter is used for the producers. From you comment, I assume that the Exasol is used as consumer so maybe it is not affecting the inserts.

You can check out the Kafka connect configuration parameters here.

Interesting parameters might be these:

  • max.message.bytes
  • fetch.max.bytes
  • max.partition.fetch.bytes

@kamrankhan1
Copy link
Author

kamrankhan1 commented Aug 30, 2019 via email

@morazow
Copy link
Contributor

morazow commented Sep 2, 2019

Hello @kamrankhan1,

The batching is not done from connector side but instead from Kafka itself. There are many parameters which you can try out. I agree it can be frustrating though.

Please have look into this discussion, it asks similar question. Additionally, you can check out these parameters:

  • batch.max.rows
  • poll.interval.ms

I hope these are helpful.

Best

@kamrankhan1
Copy link
Author

kamrankhan1 commented Sep 4, 2019 via email

@smaspe
Copy link

smaspe commented Jun 19, 2020

Hi,

We've been investigating what appears to be the same issue, so I can add some of our findings:

  • This issue happens whenever a batch of > 1 item is "upserted" (no issue with simple "insert" mode)
  • The exact error is "Feature not supported: Prepared statement with multiple row count results"
  • The SQL result code is 0A000, which means "Feature not supported"

Based on that, I believe the "MERGE" query cannot be used in a batched prepared statement (see below for reproduction that should be enough proof of that).

There doesn't seem to be an easy way to go around this:

  • I can't think of another way to "upsert" in exasol beside using merge
  • It is possible to use a single merge query to upsert all the values of the batch at once, but that would require some significant re-architecturing in kafka-connect

Reproduction

The error is easy to reproduce. Assuming you have a table SOME_TABLE in a schema SOME_SCHEMA, with some columns "id" and "value":

try {
    Class.forName("com.exasol.jdbc.EXADriver");
} catch (ClassNotFoundException e) {
    e.printStackTrace();
}
try (
        Connection connection = DriverManager.getConnection(
                "jdbc:exa:localhost:8888;schema=SOME_SCHEMA",
                "sys",
                "exasol"
        );
        PreparedStatement statement = connection.prepareStatement(
                "merge into SOME_SCHEMA.SOME_TABLE  using (select ? as \"id\", ? as \"value\") as incoming on target.\"id\" = incoming.\"id\"\n" +
                        "    when matched then update set target.\"value\" = incoming.\"value\" where target.\"id\" = incoming.\"id\"\n" +
                        "    when not matched then insert (\"id\", \"value\") values (target.\"id\", target.\"value\");"
        )
) {
    statement.setObject(1, "1");
    statement.addBatch();
    statement.setObject(1, "2");
    statement.addBatch();
    statement.executeUpdate();
} catch (SQLException e) {
    e.printStackTrace();
}

@morazow
Copy link
Contributor

morazow commented Jun 26, 2020

Hey @smaspe,

Thanks for the feedback!

Sorry, for the delayed reply. I am going to reproduce your suggestions and see if we can fix/solve it.

@morazow
Copy link
Contributor

morazow commented Jul 2, 2020

Hey @smaspe,

I have discussed this with colleague responsible with interfaces. Unfortunately, indeed merge with batches is not supported.

I am going to update the readme mentioning it. If you need this feature, you can open an idea ticket with us in IDEAs page.

Thanks for the reporting it!

Best

@morazow morazow added question User question documentation User guides, turorials, specifications labels Nov 30, 2020
@avinash0720
Copy link

hi @morazow ,

I am also facing this issue. I am unable to use 'upsert' mode for Exasol sink connector.

I too get below error:

[2020-12-02 17:35:55,464] WARN Write of 4 records failed, remainingRetries=9 (io.confluent.connect.jdbc.sink.JdbcSinkTask:76)
java.sql.SQLException: Feature not supported: Prepared statement with multiple row count results (Session: 1684988813808230386)

The merge query generated by kafka is correct but still I get this error.

Are you aware of any work around for this upsert issue? Could you please suggest me some alternative.

Thanks,
Avinash

@morazow
Copy link
Contributor

morazow commented Dec 3, 2020

Hello @avinash0720,

Yes, unfortunately, it is not possible to use Exasol MERGE statement with batches.

One alternative is to use UDF based import from Kafka into Exasol.

At the moment, I am not aware of the ongoing work to support this feature. Please ask in the community or open an IDEA ticket so that our Product Management can assess the request.

@redcatbear redcatbear added source:external Issue was created by or on behalf of someone outside the organization and removed question User question labels May 17, 2021
@morazow
Copy link
Contributor

morazow commented Jul 11, 2022

This project has been discontinued. Please use exasol/kafka-connector-extension for integration with Apache Kafka.

@morazow morazow closed this as completed Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation User guides, turorials, specifications source:external Issue was created by or on behalf of someone outside the organization
Projects
None yet
Development

No branches or pull requests

5 participants