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

Race in DistributionWithContentFilter can lead to 500 #4766

Closed
mdellweg opened this issue Nov 23, 2023 · 0 comments · Fixed by #4767
Closed

Race in DistributionWithContentFilter can lead to 500 #4766

mdellweg opened this issue Nov 23, 2023 · 0 comments · Fixed by #4767
Labels

Comments

@mdellweg
Copy link
Member

The only possible explanation I can find is that cast is messing up the related prefetched models, while acutally not be needed.
All we need is the class of the distribution. Not the detail instance.

    for dist in qs.exclude(repository=None).prefetch_related("repository__versions"):
        if dist.cast().SERVE_FROM_PUBLICATION:
            versions = dist.repository.versions.values_list("pk", flat=True)
            ....
pulp [c19d4bd0-3b4c-4d3a-87fb-9cd2b5c2edd2]: django.request:ERROR: Internal Server Error: /pulp/api/v3/distributions/file/file/
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/mixins.py", line 38, in list
    queryset = self.filter_queryset(self.get_queryset())
  File "/usr/local/lib/python3.8/site-packages/rest_framework/generics.py", line 150, in filter_queryset
    queryset = backend().filter_queryset(self.request, queryset, self)
  File "/usr/local/lib/python3.8/site-packages/django_filters/rest_framework/backends.py", line 74, in filter_queryset
    return filterset.qs
  File "/usr/local/lib/python3.8/site-packages/django_filters/filterset.py", line 230, in qs
    qs = self.filter_queryset(qs)
  File "/usr/local/lib/python3.8/site-packages/django_filters/filterset.py", line 213, in filter_queryset
    queryset = self.filters[name].filter(queryset, value)
  File "/usr/local/lib/python3.8/site-packages/pulpcore/app/viewsets/custom_filters.py", line 424, in filter
    versions = dist.repository.versions.values_list("pk", flat=True)
AttributeError: 'NoneType' object has no attribute 'versions'
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Nov 23, 2023
This change adds a `detail_model` property to the master-detail concept
and removes a race condition by replacing calls to `cast` with it in
`DistributionWithContentFilter`.

fixes pulp#4766
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Nov 23, 2023
This change adds a `detail_model` property to the master-detail concept
and removes a race condition by replacing calls to `cast` with it in
`DistributionWithContentFilter`.

fixes pulp#4766
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Nov 23, 2023
This change adds a `detail_model` property to the master-detail concept
and removes a race condition by replacing calls to `cast` with it in
`DistributionWithContentFilter`.

fixes pulp#4766
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Nov 29, 2023
This change adds a `detail_model` property to the master-detail concept
and removes a race condition by replacing calls to `cast` with it in
`DistributionWithContentFilter`.

fixes pulp#4766
mdellweg added a commit to mdellweg/pulpcore that referenced this issue Nov 29, 2023
This change adds a `detail_model` property to the master-detail concept
and removes a race condition by replacing calls to `cast` with it in
`DistributionWithContentFilter`.

fixes pulp#4766
@ggainey ggainey closed this as completed in ad0f105 Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants