I’m writing a site on GAE-Java + Objectify which lets users create their own pages, with unique URL. I haven’t been able to figure out a clear way to ensure that when two users try to claim the same url at the same time, only one user gets it.
This is what I’m trying to avoid:
- User 1 does a check – its available
- User 2 does a check – its available
- Meanwhile, User 1 creates page and stores it.
- User 2 creates a page and overwrites User 1.
Any ideas on how to solve this on GAE?
Why not just run your code in a transaction? I don’t see where the issue is. Do you have a sample of something you’ve tried and had problems with?