Response to my previous message (which was not visible on the forum yet):
Upsert seems to help regarding duplicate key value exceptions.
I do not know how much it affects to performance: Bulk inserts vs Bulk upserts.
https://www.cockroachlabs.com/docs/stable/upsert.html