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

add a select_for_update lock #76

Merged
merged 2 commits into from
Dec 3, 2021
Merged

Conversation

benjiec
Copy link
Contributor

@benjiec benjiec commented Dec 3, 2021

No description provided.

@benjiec benjiec requested a review from bhyman December 3, 2021 17:27
Copy link
Collaborator

@bhyman bhyman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One potential transaction-related issue, but if it's actually an issue, it's not newly introduced in this MR. Looks good to me.

@@ -510,6 +510,11 @@ def find_root_genome(genome):


def lock_genome(genome):
"""
Do a select for update, which, when executed inside a transaction, places a
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I only spent two minutes poking into this, but from what I could tell, the places where you call lock_genome aren't inside transactions. Unless they're happening higher up in the call chain...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. It's upstream caller that's calling the atomic, because you need the locking and the rest of the work to happen all within a transaction. Should I change the method name to lock_genome_call_if_in_transaction? or you think the comment is sufficient.

"""

fragments = Fragment.objects.select_for_update().filter(pk=self.id)
# Lock only happens when querset is evaluated, therefore need to do at least fragments[0]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless querset is a "short" name I'm not familiar with, I assume you meant queryset here. Not that it matters given that it's a comment...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, typo, will fix. Thanks.

@benjiec benjiec merged commit 13e85b6 into master Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants