Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent the execution of clearBatch() when executeBatch throws an exception. #1629

Open
erinerum opened this issue May 11, 2024 · 3 comments
Labels

Comments

@erinerum
Copy link

When the executeBatch method is executed and the process throws an exception, the InputBasedPreparedStatement.executeAny method clears the content of the generated preparedStatement by invoking the clearBatch() method. This makes it impossible to create a retry system when the exception is generated by a recoverable issue.

In implementations where batches of more than one million elements are being processed, the most efficient way to store the data is directly in the driver's preparedStatement. This way, the data is saved serialized, saving a large amount of memory. The execution of the clearBatch method prevents this possibility and forces redundant data storage.

Adding the ability to include a property to disable automatic clearBatch when an exception occurs would make the driver offer more flexible solutions when performing huge numbers of insertions on the server.

@chernser chernser added the bug label May 13, 2024
@chernser
Copy link
Contributor

@erinerum thank you for reporting the issue.

Btw, what is initial format from which data is getting to prepared statement? Is it possible to use plain java client with one of supported formats (like JSONEachRow) to stream data from input to server by passing JDBC complexity?

@erinerum
Copy link
Author

Thank you for the quick response. The use of the JDBC client has been proposed as an additional abstraction layer. However, exploring the use of the Java client could be very interesting. Thank you for the suggestion!

@chernser
Copy link
Contributor

@erinerum btw, there is a Slack Community where you may ask questions about ClickHouse https://clickhouse.com/slack
We are glad to help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants