Hi @Darrel_Rendell and welcome in the MongoDB Community
!
From what I’m reading, it sounds like you want to insert the document if it doesn’t exist and update it if it already exists in your database. So it sounds like you would like to use an upsert which does exactly that.
Also, because you apparently have big batches, you want to use the BulkWrite operation combined with many insertOne with the upsert: true option.
This will avoid this logic of try / fail / retry with an update that you have implemented. As the IP address is your key apparently, you can use this for your filter for the upsert operation.
Cheers,
Maxime.