Skip to content

Commit

Permalink
Merge pull request #1398 from dandi/zarr-locking-enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
danlamanna committed Dec 19, 2022
2 parents 97d1c5c + 6709a39 commit 13b6fd0
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions dandiapi/zarr/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ def create(self, request):
@action(methods=['POST'], detail=True)
def upload(self, request, zarr_id):
"""Start an upload of files to a zarr archive."""
# reset select_related to prevent locking additional rows
queryset = self.get_queryset().select_related(None).select_for_update()
queryset = self.get_queryset().select_for_update(of=['self'])
with transaction.atomic():
zarr_archive: ZarrArchive = get_object_or_404(queryset, zarr_id=zarr_id)
if zarr_archive.status == ZarrArchiveStatus.INGESTING:
Expand Down Expand Up @@ -218,8 +217,7 @@ def upload(self, request, zarr_id):
@action(methods=['POST'], url_path='upload/complete', detail=True)
def upload_complete(self, request, zarr_id):
"""Finish an upload of files to a zarr archive."""
# reset select_related to prevent locking additional rows
queryset = self.get_queryset().select_related(None).select_for_update()
queryset = self.get_queryset().select_for_update(of=['self'])
with transaction.atomic():
zarr_archive: ZarrArchive = get_object_or_404(queryset, zarr_id=zarr_id)
if not self.request.user.has_perm('owner', zarr_archive.dandiset):
Expand Down

0 comments on commit 13b6fd0

Please sign in to comment.