PolicyEngine / PolicyEngine/policyengine-api
`user_profile.py` create operation is not atomic
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 18
- Forks
- 33
- Avg merge
- 23h 40m
- Merged PRs (30d)
- 22
Description
- Does a select to see if a user already exists and then
- Does an insert if not.
This is not atomic so if I call it twice quickly I can get intermittently different behavior.
I am creating this issue to track the problem and come back to fix it later after addressing https://github.com/PolicyEngine/policyengine-api/issues/1989
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with issue 1989, which the author says must be addressed first, then inspect policyengine_api/endpoints/user_profile.py lines 19-57. Reproduce two quick create calls and observe the differing outcomes. Done means concurrent calls produce consistent behavior without the select-then-insert race.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100