The use of ctdbBatchInsert was found to cause heap corruption in rarely encountered situations involving variable-length records if the number of records was very close to the size of the batch buffer. The logic has been rewritten to correctly handle this situation.