cmciosu / hemp-db

https://hempdb.vercel.app/
MIT License
1 stars 1 forks source link

Company Edit Concurrency #114

Closed paullpp closed 3 months ago

paullpp commented 3 months ago

To prevent any race condition issues when two people edit the same company at the same time, we should switch from using .get() to .select_for_update() when retrieving the company to be edited.

In helloworld/views.py, we retrieve the company to be edited like this:

company = Company.objects.get(id = id)
... edit logic

that should instead use .select_for_update(), which causes the object to be locked across all other transactions happening, preventing any double-edits

paullpp commented 3 months ago

looks like we don't actually need this