Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle concurrent settings saving operations #2317

Merged
merged 2 commits into from
Feb 16, 2024

Conversation

nelsonkopliku
Copy link
Member

@nelsonkopliku nelsonkopliku commented Feb 15, 2024

Description

Fix for concurrent calls to save settings operation.

Currently if two, or more, concurrent requests come to save settings, the database says: ok, I have nothing, you can proceed with insertion to both, or all, requests resulting in multiple records being inserted which later breaks logic relying on the fact we do want only one record there.

The new migration adds a uniqueness constraint and sets a default value for the id, so we don't need to really pass it around in the code and takes care of reusing a previously inserted id, if any.

How was this tested?

Current tests cover desired behavior. Concurrency tested manually.

Reopened as we're trying to figure out what way to go #2327

@nelsonkopliku nelsonkopliku force-pushed the fix-concurrency-on-save-suma-settings branch from 2aba975 to 0757d3b Compare February 15, 2024 08:37
@nelsonkopliku nelsonkopliku self-assigned this Feb 15, 2024
@nelsonkopliku nelsonkopliku added bug Something isn't working enhancement New feature or request labels Feb 15, 2024
@nelsonkopliku nelsonkopliku force-pushed the fix-concurrency-on-save-suma-settings branch from 21cbcb9 to b13e055 Compare February 15, 2024 08:49
@nelsonkopliku nelsonkopliku added the elixir Pull requests that update Elixir code label Feb 15, 2024
@dottorblaster
Copy link
Contributor

I don't like this solution since we shouldn't enforce constrants on the dabase layer that really belong to domain. Due to the current implementation this is a compromise that the team is taking in order not to rewrite anything.

LGTM

@dottorblaster dottorblaster merged commit 71d82d7 into main Feb 16, 2024
46 checks passed
@dottorblaster dottorblaster deleted the fix-concurrency-on-save-suma-settings branch February 16, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working elixir Pull requests that update Elixir code enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

None yet

2 participants