mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-11 21:10:29 +01:00
Error upgrading from 4.0.11 to 4.1.0 #10200
Closed
opened 2025-12-29 21:28:07 +01:00 by adam
·
27 comments
No Branch/Tag Specified
main
update-changelog-comments-docs
feature-removal-issue-type
20911-dropdown
20239-plugin-menu-classes-mutable-state
21097-graphql-id-lookups
feature
fix_module_substitution
20923-dcim-templates
20044-elevation-stuck-lightmode
feature-ip-prefix-link
v4.5-beta1-release
20068-import-moduletype-attrs
20766-fix-german-translation-code-literals
20378-del-script
7604-filter-modifiers-v3
circuit-swap
12318-case-insensitive-uniqueness
20637-improve-device-q-filter
20660-script-load
19724-graphql
20614-update-ruff
14884-script
02496-max-page
19720-macaddress-interface-generic-relation
19408-circuit-terminations-export-templates
20203-openapi-check
fix-19669-api-image-download
7604-filter-modifiers
19275-fixes-interface-bulk-edit
fix-17794-get_field_value_return_list
11507-show-aggregate-and-rir-on-api
9583-add_column_specific_search_field_to_tables
v4.5.0
v4.4.10
v4.4.9
v4.5.0-beta1
v4.4.8
v4.4.7
v4.4.6
v4.4.5
v4.4.4
v4.4.3
v4.4.2
v4.4.1
v4.4.0
v4.3.7
v4.4.0-beta1
v4.3.6
v4.3.5
v4.3.4
v4.3.3
v4.3.2
v4.3.1
v4.3.0
v4.2.9
v4.3.0-beta2
v4.2.8
v4.3.0-beta1
v4.2.7
v4.2.6
v4.2.5
v4.2.4
v4.2.3
v4.2.2
v4.2.1
v4.2.0
v4.1.11
v4.1.10
v4.1.9
v4.1.8
v4.2-beta1
v4.1.7
v4.1.6
v4.1.5
v4.1.4
v4.1.3
v4.1.2
v4.1.1
v4.1.0
v4.0.11
v4.0.10
v4.0.9
v4.1-beta1
v4.0.8
v4.0.7
v4.0.6
v4.0.5
v4.0.3
v4.0.2
v4.0.1
v4.0.0
v3.7.8
v3.7.7
v4.0-beta2
v3.7.6
v3.7.5
v4.0-beta1
v3.7.4
v3.7.3
v3.7.2
v3.7.1
v3.7.0
v3.6.9
v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3-r1
v1.0.3
1.0.0
Labels
Clear labels
beta
breaking change
complexity: high
complexity: low
complexity: medium
needs milestone
netbox
pending closure
plugin candidate
pull-request
severity: high
severity: low
severity: medium
status: accepted
status: backlog
status: blocked
status: duplicate
status: needs owner
status: needs triage
status: revisions needed
status: under review
topic: GraphQL
topic: Internationalization
topic: OpenAPI
topic: UI/UX
topic: cabling
topic: event rules
topic: htmx navigation
topic: industrialization
topic: migrations
topic: plugins
topic: scripts
topic: templating
topic: testing
type: bug
type: deprecation
type: documentation
type: feature
type: housekeeping
type: translation
Mirrored from GitHub Pull Request
No Label
Milestone
No items
No Milestone
Projects
Clear projects
No project
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: starred/netbox#10200
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @avbor on GitHub (Sep 6, 2024).
Deployment Type
Self-hosted
NetBox Version
v4.1.0
Python Version
3.12
Steps to Reproduce
Trying to upgrade from 4.0.11 to 4.1.0 rise migration error.
Expected Behavior
No errors during upgrade.
Observed Behavior
Please don't close this issue without investigate, we have several closed unresolved issues in this repo and netbox-docker.
Like https://github.com/netbox-community/netbox/issues/17352 and https://github.com/netbox-community/netbox-docker/issues/1314
In https://github.com/netbox-community/netbox-docker/issues/1313 @tobiasge wrote
Needs to be fixed in Netbox itself.https://github.com/netbox-community/netbox-docker/issues/1313#issuecomment-2333929966Also some discussions abount this problem - https://github.com/netbox-community/netbox/discussions/17382 and https://github.com/netbox-community/netbox/discussions/17388
Log from netbox side:
log from postgre:
Also, is it normal to first go renaming the table (
ALTER TABLE "extras_objectchange" RENAME TO "core_objectchange") and then select from the old name(SELECT "extras_objectchange"."id", "extras_objectchange"."time", "extras_objectchange"."user_name", "extras_objectchange"."request_id", "extras_objectchange"."action", "extras_objectchange"."changed_object_id", "extras_objectchange"."related_object_id", "extras_objectchange"."object_repr", "extras_objectchange"."prechange_data", "extras_objectchange"."postchange_data", "extras_objectchange"."changed_object_type_id", "extras_objectchange"."related_object_type_id", "extras_objectchange"."user_id" FROM "extras_objectchange" WHERE "extras_objectchange"."changed_object_type_id" IN (166) ORDER BY "extras_objectchange"."time" DESC)?@jeremystretch commented on GitHub (Sep 6, 2024):
Bug reports are not to be used for upgrade support. Per the bug report template:
We know that simply installing NetBox v4.0.11 and upgrading to v4.1.0 works as expected, so you'll need to identify steps that someone else can take to reproduce this issue if you want it to be investigated as a bug. These steps must not involve the Docker container, as that is out of scope for this project.
Once you've done that, please update the "Steps to Reproduce" section in your post above with the necessary detail.
@avbor commented on GitHub (Sep 6, 2024):
Very strange approach, migration procedures are kind of part of the product, aren't they?
I have provided several links to issues and discussions where other users have encountered the same problem.
As I wrote above, issues in the netbox-docker repository are closed without review and indicate the need to create an issue in that repository.
It all seems like a vicious circle.
It turns out that users simply don't have the opportunity to create an issue in the "right place".
I and other users encountering the problem have no other steps to take other than trying to upgrade the product.
@jeremystretch commented on GitHub (Sep 6, 2024):
I never suggested otherwise. If you can point to a bug in the migration procedure, we'll happy to address it. But to do that, you first need to provide steps to reproduce the reported behavior, as I asked. Migrations can fail for any number of reasons, such as corrupt or missing data. This does not necessarily indicate a bug in NetBox.
@avbor commented on GitHub (Sep 6, 2024):
I'd love to describe the specific steps, but there is only one step - trying to upgrade an existing netbox installation. Judging by the discussions, different users have tried different ways to reproduce the problem, but the result is the same.
For example:
I successfully exported the NetBox database version 4.0.7 with PostgreSQL version 16.3 and imported it onto a new fresh Netbox 4.1.0 install. Unfortunately, the following error occurs when running the upgrade script sudo /opt/netbox/upgrade.sh.I tried the same, made new instance, made fresh install, the dropped netbox DB, created new and wrote a dump from last worked version. It didn't help at all.That's true, but without help from developers, we're unlikely to find the problem. What is required of us to find the problem?
Database dumps, logs, something else?
And I want to pay attention to this point - judging by postgresql logs, during the migration procedure (0117_move_objectchange), first the table is renamed, and then an attempt to select by the old name is made:
This seems a bit odd, would this not help in finding the problem?
@kovacs-andras commented on GitHub (Sep 6, 2024):
Similar problem here, in-place upgrade didn't work, now I can't revert.
@jeremystretch commented on GitHub (Sep 6, 2024):
Ok, let's do that "one step." You said:
So let's do that:
upgrade.shsuccessfullyAll the migrations complete successfully, as expected:
So, what's different about what you're doing?
@quantum909 commented on GitHub (Sep 7, 2024):
Thank you very much for NetBox and the described steps.
Since I have the same problem importing my NetBox 4.0.7 database (PostgreSQL 16.3) into NetBox 4.1.0 I have tested it with the v4.0 demo data and the same error appears as with my exported 4.0.7 database.
Installation of NetBox 4.1.0 on a newly installed Ubuntu 24.04.1 LTS. NetBox runs as expected
Loading the v4.0 demo data as described here or here into NetBox 4.1.0 then fix the permission problem with
GRANT ALL ON SCHEMA public TO netbox.Now when I run
python netbox/manage.py migrateor runupgrade.shI get the same error message with the v4.0 demo data in NetBox 4.1.0 as with my exported 4.0.7 database.@candlerb commented on GitHub (Sep 7, 2024):
See https://github.com/netbox-community/netbox/discussions/17379#discussioncomment-10576206
From that, it appears to be that migration dependencies haven't been declared properly, so they are applied in a non-deterministic order. Hence it works for some people and not for others.
Making this something that could be reproduced would be difficult: I don't know what affects the order in which they're applied (e.g. the order in which the files were created in the directory?)
It might be a good idea if the migrations were sorted by name, so that any which don't explicitly depend on each other are still applied in a deterministic order, but that could involve changing the internals of the migrations library.
@avbor commented on GitHub (Sep 7, 2024):
Not sure about this.
Migration
0117_move_objectchange.pyfalls on16f74f7b03/netbox/extras/migrations/0117_move_objectchange.py (L8)i.e. all code up to
16f74f7b03/netbox/extras/migrations/0117_move_objectchange.py (L116)is executed normally.We can see it in postgre log (ALTER TABLE, ALTER INDEX... etc).
But, when it comes to the
update_content_typesfunction a SELECT from an already deleted table happens (SELECT "extras_objectchange"."id",...).But, I understand absolutely nothing about django and very little about python =(
@avbor commented on GitHub (Sep 8, 2024):
Great suggestion about 0011_move_objectchange - https://github.com/netbox-community/netbox/discussions/17388#discussioncomment-10582898
In my case, in addition to deleting this entry, it was also necessary to delete the redis caches - https://github.com/netbox-community/netbox/discussions/17388#discussioncomment-10583097
After that, the netbox successfully updated and started up!
@amhn commented on GitHub (Sep 8, 2024):
As I said in the comment linked by @avbor the problem is that extras.0117_move_objectchange depends on core.0011_move_objectchange running in the same migration run. This would not be a problem, but core.0011_move_objectchange
If the second migration fails, the user is left with a state that is not recoverable without manual intervention. I do not know if it is possible to prevent the failure on the second run.
Reproduction:
@candlerb commented on GitHub (Sep 9, 2024):
May or may not be related, but there is a reported dependency issue with
core_configrevisionin0062_clear_secrets_changelog.py, see https://github.com/netbox-community/netbox/discussions/17412#discussioncomment-10588147This is on a database being upgraded from v2.11.11 to v3.7.8 schema.
@quantum909 commented on GitHub (Sep 10, 2024):
After the problem has been recognized and a manual fix is ready. What would be the best course of action now? Better to wait if it is possible to fix this problem with a future update. Or make the appropriate fixes yourself with the risk that future updates could cause problems again.
@jeremystretch commented on GitHub (Sep 10, 2024):
We still have not identified the source of the failure. As demonstrated above, upgrading from v4.0.11 to v4.1.0 does not reproduce the issue; at least not with Python 3.10 and PostgreSQL 14.
@amhn indicated in another thread that the initial failure was due to missing permissions:
It's not clear to me why this would be an issue if you're simply upgrading an existing database as suggested in the discussion above, as the necessary permissions should already be in place.
As for backing out
core.0011_move_objectchange, you can run the management commandmanage.py migrate core 0010to undo the application of the migration. However, it's also not clear why that would be necessary as each migration should be atomic AFAIK.@avbor commented on GitHub (Sep 10, 2024):
I think it could be any of the problems in the migration process. For @amhn it was a permissions issue, for me I suspect it was a redis issue.
As a result, it turns out that in case of any problem interfering with the migration, we first of all get a non-obvious error ("extras_objectchange" does not exist), and secondly, even after solving this problem, we cannot move on without manual rollback core.0011_move_objectchange (direct in DB or through manage.py migrate core 0010).
@amhn commented on GitHub (Sep 10, 2024):
I think the problem here is using SeparateDatabaseAndState:
https://docs.djangoproject.com/en/5.1/ref/migration-operations/#separatedatabaseandstate
I think after the
core.0011_move_objectchangestate and database are out of sync. Because this migration created a new Model but no corresponding database change.I do not know if there is a better way to move a model between apps. This one [https://realpython.com/move-django-model/#the-django-way-rename-the-table] suggests deleting the old object and renaming the table in the first part of the migration.
Since this is triggered by a misconfiguration of the database or in the netbox-docker case of the redis/valkey service, it might not be worth the effort to fix it. Plain upgrades should just work.
@avbor I also hit the redis/valkey issue, although I could not reproduce it without netbox-docker, even after stopping the redis server I was using for the replication of this issue.
@avbor commented on GitHub (Sep 10, 2024):
Maybe the root of the problem here is replacing redis with valkey.
But I still see some incorrectness here, no matter what kind of problem happened in the process, but even after solving it, it is impossible to continue the update\migration without manual intervention.
And the errors that are generated make the situation even more confusing, at least for me =)
@FrankPGH commented on GitHub (Sep 10, 2024):
Just want to point out that I experienced that permissions issue with the public schema and never had it before. 4.0.10 was working perfectly for me, the install is bog standard, and no permissions should have changed prior to performing the upgrade.
@mikygee commented on GitHub (Sep 10, 2024):
Hello,
I don't understand what you did to solve the problem.
I did
delete from django_migrations WHERE name='0011_move_objectchange';Flushed the redis cache
manage.py migrate core 0010Nothing worked for me.
@rfdrake commented on GitHub (Sep 11, 2024):
Here is what I did to get this working again:
The redis changes are probably only needed if you're using docker. The switch from redis to valkey causes the database to be different. It might be good to check the status of redis connectivity before the migration as a way to defend against this.
Or something can watch for errors like these:
@mikygee commented on GitHub (Sep 12, 2024):
Hello Robert,
It didn't work for me. Also I don't user docker.
I made a database restauration and restarted the upgrarde process up to 4.0.11
@KaleBrink commented on GitHub (Sep 12, 2024):
I have the same problem. Upgrade from 4.0.11 to 4.1.0 using the steps from the Netbox documentation, Below the error from the upgrade.
And from the postgres log.
Only difference is the Python version used. I have python 3.10
@mmahacek commented on GitHub (Sep 12, 2024):
@rfdrake Your steps worked perfectly to fix my netbox-docker upgrade from 4.0.11 -> 4.1.0. Thanks!
@FrankPGH commented on GitHub (Sep 13, 2024):
I was finally able to successfully upgrade from 4.0.11 to 4.1.1 by fixing the broken permissions prior to running upgrade.sh.
https://github.com/netbox-community/netbox/discussions/17388#discussioncomment-10638981
@kovacs-andras commented on GitHub (Sep 16, 2024):
It worked! Very many thanks! 🥇
@Cbrad24 commented on GitHub (Sep 18, 2024):
@KaleBrink had the same issue,
NumericValueOutOfRange: integer out of range. For me I had to go into my Postgres DB and null out the value of thediskcolumn for one particular Virtual Machine in the tablevirtualization_virtualmachinethat had a very large integer value, and when Netbox was multiplying it by 1,000 the value was overflowing the maximum value.@jeremystretch commented on GitHub (Sep 18, 2024):
It's evident that this issue has become a dumping ground for various unrelated problems, so I'm going to convert it to a discussion.