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

Concurrency problem with healthcheck #151

Open
marcusgc opened this issue Jan 25, 2019 · 1 comment
Open

Concurrency problem with healthcheck #151

marcusgc opened this issue Jan 25, 2019 · 1 comment
Labels
hacktoberfest opensource.globo.com/hacktoberfest

Comments

@marcusgc
Copy link
Collaborator

Class below is called when creating a new pool. When two requests are trying to create a healthcheck with the same identifier, it can be duplicated on the DB, causing next requests with same data to fail, as it would return two objects on get().
Need to change code to avoid this from happening. Use lock?

networkapi.healthcheckexpect.models:
class Healthcheck(BaseModel):
def get_create_healthcheck(self, healthcheck):
try:
hc = Healthcheck.objects.get(**healthcheck)
except ObjectDoesNotExist:
hc = Healthcheck(**healthcheck)
hc.save()

@laurapanzariello laurapanzariello added the hacktoberfest opensource.globo.com/hacktoberfest label Oct 2, 2019
@lucassouto
Copy link

Using unique_together I believe would solve, what do you think?

brunojuliao added a commit to brunojuliao/GloboNetworkAPI that referenced this issue Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest opensource.globo.com/hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants