Uniqueness of rows

Yes, you’re right. Because the operations are not atomic, there is always a small chance that collisions can happen and you wind up with duplicates.

A while back, David suggested using something like Upstash with Redis to handle this. I’ve not had a need to try it yet, but I’ve been keeping it in the back of my mind should that need arise.