Repository navigation
Remove interval content query experiment #1715
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from django.db import migrations | ||
|
|
||
| _INDEX_NAME = "core_ca_relpath_pattern_idx" | ||
| _INDEX_MARKER = "pulp-service:0024:core_ca_relpath_pattern_idx" | ||
| _DROP_INDEX_SQL = f'DROP INDEX CONCURRENTLY IF EXISTS "{_INDEX_NAME}"' | ||
|
|
||
|
|
||
| def remove_experiment_index(apps, schema_editor): # noqa: ARG001 | ||
| """Remove only the index owned by the temporary pulp-service migration.""" | ||
| with schema_editor.connection.cursor() as cursor: | ||
| cursor.execute( | ||
| """ | ||
| SELECT obj_description(indexrel.oid, 'pg_class') | ||
| FROM pg_class AS indexrel | ||
| JOIN pg_namespace AS namespace ON namespace.oid = indexrel.relnamespace | ||
| WHERE indexrel.relname = %s AND namespace.nspname = current_schema() | ||
| """, | ||
| [_INDEX_NAME], | ||
| ) | ||
| row = cursor.fetchone() | ||
| if row and row[0] == _INDEX_MARKER: | ||
| cursor.execute(_DROP_INDEX_SQL) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Directory listings become slow When a directory listing runs after this migration, especially on a large repository, Keep or add an index that supports the prefix queries for as long as directory listings use them. Prompt for AI agentsIn `pulp_service/pulp_service/app/migrations/0025_remove_experiment_relative_path_index.py` at line 22:
**Directory listings become slow**
When a directory listing runs after this migration, especially on a large repository, `remove_experiment_index` drops the `text_pattern_ops` index while directory-listing queries still filter artifacts with `relative_path__startswith`; PostgreSQL scans the artifact tables and directory listings become slow.
Keep or add an index that supports the prefix queries for as long as directory listings use them.
sourcery-ai[bot] marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. security (python.sqlalchemy.security.sqlalchemy-execute-raw-query): Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option. Source: opengrep |
||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| """Remove the temporary index before pulpcore owns the replacement.""" | ||
|
|
||
| atomic = False # DROP INDEX CONCURRENTLY cannot run in a transaction. | ||
|
|
||
| dependencies = [ | ||
| ("service", "0026_andgatecontentguard"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(remove_experiment_index, migrations.RunPython.noop), | ||
| ] | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium · Release notes omit the cleanup
When towncrier builds release notes for this change,
CHANGES/has no fragment for this index-removal migration, so Towncrier omits the cleanup from the release notes.Add a Towncrier fragment documenting the index cleanup.
Also at
pulp_service/pulp_service/app/migrations/0025_remove_experiment_relative_path_index.py:35.Prompt for AI agents
From
CLAUDE.mdL76: