diff --git a/CHANGES/6772.bugfix b/CHANGES/6772.bugfix new file mode 100644 index 00000000000..d68f13b8923 --- /dev/null +++ b/CHANGES/6772.bugfix @@ -0,0 +1 @@ +Fixed the new content set optimization failing when the RepositoryVersion grew larger than 65K content units. diff --git a/pulpcore/app/models/repository.py b/pulpcore/app/models/repository.py index 0dc3ad50cc5..fdbfb12c353 100644 --- a/pulpcore/app/models/repository.py +++ b/pulpcore/app/models/repository.py @@ -890,7 +890,15 @@ def get_content(self, content_qs=None): if content_qs is None: content_qs = Content.objects - return content_qs.filter(pk__in=self._get_content_ids()) + content_ids = self._get_content_ids() + if isinstance(content_ids, list) and len(content_ids) >= 65535: + # Workaround for PostgreSQL's limit on the number of parameters in a query + content_ids = ( + RepositoryVersion.objects.filter(pk=self.pk) + .annotate(cids=Func(F("content_ids"), function="unnest")) + .values_list("cids", flat=True) + ) + return content_qs.filter(pk__in=content_ids) @property def content(self):