clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

The ClickHouse Data Processor’s write position does not revert to its original state after an exception is triggered by the addBatch() method.

Open vatisteve opened this issue 2 years ago • 0 comments

Error: The ClickHouseDataProcessor doesn't reset the write position after encountering exceptions during addBatch(). This leads to subsequent batches using the wrong position and failing with serialization errors.

Scenario:

  • Calling addBatch() with invalid data (null for non-nullable or wrong data type) throws a SqlException.
  • The write position remains at the previous attempt (not reset to 0).
  • Adding the next batch with the incorrect position causes a serializer exception due to mismatched data and serialization method.

Question:

  • How can we reset the write position of ClickHouseDataProcessor after handling addBatch() exceptions?
  • Alternatively, is there a way to add subsequent batches without relying on the potentially incorrect write position?

I was debugging and saw the wrong value here: image

I tried using the clearParameters() method in my catch block but it hasn't got any effect.

vatisteve avatar Nov 18 '23 09:11 vatisteve