Bulk insertion of documents with connection error handling