batch.Send marks batch as sent even there are errors
Issue description
The Send method marks batch as sent with any outcome, even if there is some error occurred. There is no way to retry batch sending in case of any issues.
https://github.com/ClickHouse/clickhouse-go/blob/202ca18e6dd39d9720f3fd60530ab1569c78d378/conn_batch.go#L128-L154
Is it an expected behaviour?
Configuration
OS: unrelated
Interface: native
Driver version: v2.0.12 (latest)
Go version: unrelated
ClickHouse Server version: unrelated
Thanks, @leonidboykov, for raising this. We return an err if a batch is not successful. Are you looking for automatic retries if a batch is not successful?
or would you prefer the send flag be more granular i.e. don't set the send flag if errors occur before the encoder is flushed?
@gingerwizard I think that leaving send flag as false in case of any error is fine.
ok we'll improve @leonidboykov i think we'll try to make it as close to accurate as possible - if the stream is flushed we'll set it. Any errors before it will be false.
So alittle more complexity here than i initially thought. Whilst we can in theory be more accurate on the sent flag it's there for a very good reason - when the Send method finishes the connection is released (acquired in PrepareBatch). Subsequent sends therefore fail - bad stuff happens due to memory references now nil. Now we could conditionally release the connection if sent is set to true, but this introduces other interesting questions i.e. the user is now responsible for releasing the connection on the batch. This seems potentially leaky and highly unintuitive. We could introduce a batch Close() method the user always has to call, but this is quite a breaking change.
@genzgd
Присоединяюсь.
В случае обрыва соединения, повтор не возможен ((
clickhouse: batch has already been sent

Hi, I'd like to learn the best way of retrying a failed Batch... by leveraging its data to construct a new Batch? Currently I don't see any easy way to achieve that. It can get BatchColumn's out but no obvious way to construct a Batch from BatchColumn's. Did I miss anything? Thanks!