Errors when upgrading from 3.4.3 to 4.0.8 (ipam.0064_clear_search_cache...Skipping config initialization (database unavailable)) #10061

Closed
opened 2025-12-29 21:26:20 +01:00 by adam · 1 comment
Owner

Originally created by @etigui on GitHub (Aug 7, 2024).

Deployment Type

Self-hosted

NetBox Version

3.4.3

Python Version

3.11

Steps to Reproduce

We have 2 instances, one prod with Netbox 3.4.3 and one test with Netbox 4.0.8. We are trying to upgrade from the prod to the test instance:

Prod instance (Netbox 3.4.3 with postgesql v13):

  1. Dump production database

Test instance (Netbox 4.0.8 with postgesql v16):

  1. Create database from dump
  2. Run upgrade.sh
  3. Upgrade get stuck on DB migration

Expected Behavior

Migrate Netbox from 3.4.3 (postgesql v13) to 4.0.8 (postgesql v16)

Observed Behavior

PYTHON=/usr/bin/python3.11 ./upgrade.sh
...
Applying database migrations (python3 netbox/manage.py migrate)...
Operations to perform:
  Apply all migrations: account, admin, auth, circuits, contenttypes, core, dcim, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization, vpn, wireless
Running migrations:
  Applying circuits.0042_provideraccount... OK
  Applying circuits.0043_circuittype_color... OK
  Applying core.0001_initial... OK
  Applying core.0002_managedfile... OK
  Applying core.0003_job... OK
  Applying core.0004_replicate_jobresults... OK
  Applying core.0005_job_created_auto_now... OK
  Applying core.0006_datasource_type_remove_choices... OK
  Applying core.0007_job_add_error_field... OK
  Applying core.0008_contenttype_proxy... OK
  Applying core.0009_configrevision... OK
  Applying core.0010_gfk_indexes... OK
  Applying tenancy.0010_tenant_relax_uniqueness... OK
  Applying ipam.0064_clear_search_cache...Skipping config initialization (database unavailable)
Traceback (most recent call last):
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)
psycopg.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/netbox/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/opt/netbox/netbox/ipam/migrations/0064_clear_search_cache.py", line 15, in clear_cache
    CachedValue.objects.filter(object_type=content_type).delete()
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/query.py", line 1148, in delete
    deleted, _rows_count = collector.delete()
                           ^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/deletion.py", line 506, in delete
    count = query.delete_batch(pk_list, self.using)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/sql/subqueries.py", line 42, in delete_batch
    num_deleted += self.do_query(
                   ^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/sql/subqueries.py", line 20, in do_query
    cursor = self.get_compiler(using).execute_sql(CURSOR)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
    cursor.execute(sql, params)
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/netbox/venv/lib64/python3.11/site-packages/psycopg/cursor.py", line 732, in execute
    raise ex.with_traceback(None)
django.db.utils.InternalError: current transaction is aborted, commands ignored until end of transaction block
Originally created by @etigui on GitHub (Aug 7, 2024). ### Deployment Type Self-hosted ### NetBox Version 3.4.3 ### Python Version 3.11 ### Steps to Reproduce We have 2 instances, one prod with Netbox 3.4.3 and one test with Netbox 4.0.8. We are trying to upgrade from the prod to the test instance: Prod instance (Netbox 3.4.3 with postgesql v13): 1. Dump production database Test instance (Netbox 4.0.8 with postgesql v16): 1. Create database from dump 2. Run upgrade.sh 3. Upgrade get stuck on DB migration ### Expected Behavior Migrate Netbox from 3.4.3 (postgesql v13) to 4.0.8 (postgesql v16) ### Observed Behavior ``` PYTHON=/usr/bin/python3.11 ./upgrade.sh ... Applying database migrations (python3 netbox/manage.py migrate)... Operations to perform: Apply all migrations: account, admin, auth, circuits, contenttypes, core, dcim, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization, vpn, wireless Running migrations: Applying circuits.0042_provideraccount... OK Applying circuits.0043_circuittype_color... OK Applying core.0001_initial... OK Applying core.0002_managedfile... OK Applying core.0003_job... OK Applying core.0004_replicate_jobresults... OK Applying core.0005_job_created_auto_now... OK Applying core.0006_datasource_type_remove_choices... OK Applying core.0007_job_add_error_field... OK Applying core.0008_contenttype_proxy... OK Applying core.0009_configrevision... OK Applying core.0010_gfk_indexes... OK Applying tenancy.0010_tenant_relax_uniqueness... OK Applying ipam.0064_clear_search_cache...Skipping config initialization (database unavailable) Traceback (most recent call last): File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/psycopg/cursor.py", line 732, in execute raise ex.with_traceback(None) psycopg.errors.InFailedSqlTransaction: current transaction is aborted, commands ignored until end of transaction block The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/opt/netbox/netbox/manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/__init__.py", line 436, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/base.py", line 412, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/base.py", line 458, in execute output = self.handle(*args, **options) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/base.py", line 106, in wrapper res = handle_func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/core/management/commands/migrate.py", line 356, in handle post_migrate_state = executor.migrate( ^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate state = self._migrate_all_forwards( ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards state = self.apply_migration( ^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration state = migration.apply(state, schema_editor) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/migration.py", line 132, in apply operation.database_forwards( File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards self.code(from_state.apps, schema_editor) File "/opt/netbox/netbox/ipam/migrations/0064_clear_search_cache.py", line 15, in clear_cache CachedValue.objects.filter(object_type=content_type).delete() File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/query.py", line 1148, in delete deleted, _rows_count = collector.delete() ^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/deletion.py", line 506, in delete count = query.delete_batch(pk_list, self.using) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/sql/subqueries.py", line 42, in delete_batch num_deleted += self.do_query( ^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/sql/subqueries.py", line 20, in do_query cursor = self.get_compiler(using).execute_sql(CURSOR) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql cursor.execute(sql, params) File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute return self._execute_with_wrappers( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers return executor(sql, params, many, context) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute with self.db.wrap_database_errors: File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/utils.py", line 91, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/opt/netbox/venv/lib64/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/netbox/venv/lib64/python3.11/site-packages/psycopg/cursor.py", line 732, in execute raise ex.with_traceback(None) django.db.utils.InternalError: current transaction is aborted, commands ignored until end of transaction block ```
adam closed this issue 2025-12-29 21:26:20 +01:00
Author
Owner

@AADIP commented on GitHub (Aug 7, 2024):

IIRC you'll need to be on 3.7.x to upgrade into 4.x.x.

https://netboxlabs.com/docs/netbox/en/stable/installation/upgrading/ check the upgrade paths here.

@AADIP commented on GitHub (Aug 7, 2024): IIRC you'll need to be on 3.7.x to upgrade into 4.x.x. https://netboxlabs.com/docs/netbox/en/stable/installation/upgrading/ check the upgrade paths here.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#10061