Retriable/reusable batches
Somewhat related to #529
Suggestion. Make driver.Batch retriable and/or reusable after Send() - both for the same, or for another connection. As far as I understood from the code, driver.Batch is tied to the specific connection (guess it is fetching the column types etc from CH), however, it would be tremendously useful to be able to reuse the batch after it was sent once.
Use case
- Retrying the same batch on the same server in case of some errors
- Retrying the same batch on the different server (to the same replicated table)
- Implementing majority writes for better write durability
Right now to implement those features, client has to keep the data for the batch somewhere else, which is not only inconvenient (especially in streaming-style use-cases, where client itself does not have access to all of the data needed to be inserted to CH), but essentially doubles the memory footprint.
Agreed the coupling is annoying. This feels like a v3 feature but we might be able to achieve the behavior by allowing the connection to be reassigned after Send() - ideally it wouldn't reference at all but I suspect this might be a large change.
Also, over http we make a DESCRIBE call on prepareBatch. Reusable batches would avoid this overhead.