Skip to content

Parameter limit#7803

Draft
dralley wants to merge 2 commits into
pulp:mainfrom
dralley:parameter-limit
Draft

Parameter limit#7803
dralley wants to merge 2 commits into
pulp:mainfrom
dralley:parameter-limit

Conversation

@dralley

@dralley dralley commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

See: Pull Request Walkthrough

dralley added 2 commits June 16, 2026 12:52
PostgreSQL's wire protocol limits bind parameters to 65,535 per
statement.  When Django ORM's filter(field__in=python_list) generates
WHERE field IN ($1, $2, ..., $65536+), it exceeds this limit when
using server-side cursors (.iterator()).

This introduces a safe_in() utility that uses a custom Django lookup
(= ANY(%s)) for large lists, passing the entire list as a single
PostgreSQL array parameter regardless of size.  For small lists, the
standard __in lookup is used unchanged.

Applied safe_in() to all vulnerable code paths in pulpcore:
- RepositoryVersion.get_content(), added(), removed()
- import_repository_version() content mapping

Also updated the test to use .iterator() so it reliably exercises the
server-side cursor path that triggers the parameter limit.

Assisted-By: claude-opus-4.6
@dralley

dralley commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up to #6784

This is probably a candidate for using the "run plugin CI against pulpcore main branch" automation.

Comment thread pulpcore/app/util.py
values = list(values)
if len(values) < POSTGRES_MAX_QUERY_PARAMS:
return Q(**{f"{field_name}__in": values})
return Q(**{f"{field_name}__any_array": values})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would there be a downside when we always used this array method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants