The insert_batch function fails when the data array passed to it is empty. It is supposed to show a meaningful message when database debugging is enabled, but it doesn't. This is specially problematic if you use transactions as they remain open upon these errors and you have to manually kill them.