flush and reset_db manager commands are failing
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 598
- Forks
- 168
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 86
Description
Version
3.80.0
Describe the bug
When it's needed to remove all data from app's database, usually it's used a manager command like flush or reset_db, but both are returning an error when used:
❯ oci-env pulpcore-manager flush
2025-06-10 11:15:45,860 - INFO - utils.py:16 - USING OCI_ENV_PATH FROM ENV: /home/decko/dev/pulp/oci_env
2025-06-10 11:15:45,860 - INFO - utils.py:16 - USING OCI_ENV_PATH FROM ENV: /home/decko/dev/pulp/oci_env
2025-06-10 11:15:45,860 - INFO - utils.py:16 - USING OCI_ENV_PATH FROM ENV: /home/decko/dev/pulp/oci_env
You have requested a flush of the database.
This will IRREVERSIBLY DESTROY all data currently in the "pulp" database,
and return each table to an empty state.
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
Traceback (most recent call last):
File "/usr/local/bin/pulpcore-manager", line 8, in <module>
sys.exit(manage())
File "/usr/local/lib/python3.9/site-packages/pulpcore/app/manage.py", line 11, in manage
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/commands/flush.py", line 90, in handle
emit_post_migrate_signal(verbosity, interactive, database)
File "/usr/local/lib/python3.9/site-packages/django/core/management/sql.py", line 52, in emit_post_migrate_signal
models.signals.post_migrate.send(
File "/usr/local/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 176, in send
return [
File "/usr/local/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 177, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "/usr/local/lib/python3.9/site-packages/sentry_sdk/integrations/django/signals_handlers.py", line 73, in wrapper
return receiver(*args, **kwargs)
TypeError: _populate_access_policies() missing 1 required positional argument: 'apps'
and
❯ oci-env pulpcore-manager reset_db
2025-06-10 11:28:23,895 - INFO - utils.py:16 - USING OCI_ENV_PATH FROM ENV: /home/decko/dev/pulp/oci_env
2025-06-10 11:28:23,896 - INFO - utils.py:16 - USING OCI_ENV_PATH FROM ENV: /home/decko/dev/pulp/oci_env
2025-06-10 11:28:23,896 - INFO - utils.py:16 - USING OCI_ENV_PATH FROM ENV: /home/decko/dev/pulp/oci_env
You have requested a database reset.
This will IRREVERSIBLY DESTROY
ALL data in the database "pulp".
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
pulp [None]: root:INFO: Executing... "DROP DATABASE "pulp";"
pulp [None]: root:ERROR: Error: database "pulp" does not exist
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django_extensions/management/commands/reset_db.py", line 183, in handle
cursor.execute(drop_query)
File "/usr/local/lib/python3.9/site-packages/psycopg/cursor.py", line 97, in execute
raise ex.with_traceback(None)
psycopg.errors.InvalidCatalogName: database "pulp" does not exist
pulp [None]: root:INFO: Executing... "CREATE DATABASE "pulp" WITH OWNER = "pulp" ENCODING = 'UTF8';"
Traceback (most recent call last):
File "/usr/local/bin/pulpcore-manager", line 8, in <module>
sys.exit(manage())
File "/usr/local/lib/python3.9/site-packages/pulpcore/app/manage.py", line 11, in manage
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.9/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.9/site-packages/django_extensions/management/utils.py", line 62, in inner
ret = func(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django_extensions/management/commands/reset_db.py", line 198, in handle
cursor.execute(create_query)
File "/usr/local/lib/python3.9/site-packages/psycopg/cursor.py", line 97, in execute
raise ex.with_traceback(None)
psycopg.errors.InsufficientPrivilege: permission denied to create database
To Reproduce
1 - start pulp using your preferred way.
2 - run pulpcore-manager flush or pulpcore-manager reset_db
Expected behavior
It's expected to have the application database returned to a fresh state, without user data.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the pulpcore-manager entry point and reproduce both flush and reset_db failures. Trace the Django post_migrate error involving _populate_access_policies and the PostgreSQL reset_db permission error; done means both commands can return the application database to a fresh state without these failures.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, postgresql, python
- Domain
- backend, cli, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100