Skip to content

Lock dandiset when changing owners #2288

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

Merged
merged 1 commit into from
Apr 10, 2025

Conversation

naglepuff
Copy link
Contributor

Fixes #2000

Changes

The users endpoint for the Dandiset View now uses select_for_update. This prevents accidentally saving stale data when calleding dandiset.save().

@naglepuff naglepuff requested a review from mvandenburgh April 7, 2025 16:22
Copy link
Member

@mvandenburgh mvandenburgh left a comment

Choose a reason for hiding this comment

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

In addition to the point about the code comment, as I look at this more closely I'm having second thoughts about locking the dandiset in this manner. TLDR: I think your original solution is actually better.

We discussed this before and decided to just lock the dandiset for the duration of the entire endpoint, as is implemented here, in order to eliminate an extra DB query. But I realize now that we only need the lock when the user is sending a PUT request to modify the dandiset owners. The vast majority of calls to this endpoint will not do that, but will instead be a GET request that simply retrieves the owners list (where no lock is needed). That GET request to /users/ happens on every load of the DLP (i.e. probably 99% of calls to this endpoint are GET requests), so with the current approach we'd be adding the overhead of opening a transaction and holding a row lock to every DLP page load.

So I think I'm now convinced that your original solution of re-querying for the dandiset with SELECT FOR UPDATE is better, @naglepuff. What do you think?

Copy link
Member

@mvandenburgh mvandenburgh left a comment

Choose a reason for hiding this comment

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

LGTM

@naglepuff naglepuff force-pushed the issue-2000-lock-dandiset-for-owner-change branch from 3a762c2 to a272cc0 Compare April 8, 2025 19:39
@naglepuff naglepuff force-pushed the issue-2000-lock-dandiset-for-owner-change branch from a272cc0 to 866f7e9 Compare April 8, 2025 19:40
@naglepuff naglepuff merged commit cbc6080 into master Apr 10, 2025
11 of 15 checks passed
@naglepuff naglepuff deleted the issue-2000-lock-dandiset-for-owner-change branch April 10, 2025 14:42
@mvandenburgh mvandenburgh added the patch Increment the patch version when merged label Apr 16, 2025
@dandibot
Copy link
Member

🚀 PR was released in v0.5.0 🚀

@dandibot dandibot added the released This issue/pull request has been released. label Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lock dandiset when changing owner list
4 participants