Error Starting NetBox v2.3.7 (via Docker) - Found wrong number of constraints

464 views
Skip to first unread message

Matthew Yauch

unread,
Aug 13, 2018, 10:48:38 AM8/13/18
to NetBox
Well this was strange, been using NetBox on v2.3.7 for a decent chunk of time.  My Dockerfile is based on the ninech repo.  I stopped my Docker services, backed up my data, and tried upgrading to v2.4.3, then received the below error.  I destroyed all of the v2.4.3 attempt and tried to just start up my data from v2.3.7 to get back to usable and now I get the same error.  As far as I can tell this was just a ticking timebomb since I never restarted after upgrading to v2.3.7.

I found the following thread, but figured I'd check with Stretch for any quick fixes before running in circles experimenting.



Creating netbox_postgres_1 ... done
Creating network "netbox_default" with the default driver
Creating netbox_app_1      ... done
Creating netbox_app_1      ...
Creating netbox_nginx_1    ... done
Attaching to netbox_postgres_1, netbox_app_1, netbox_nginx_1
postgres_1  | LOG:  database system was shut down at 2018-08-13 14:38:39 UTC
postgres_1  | LOG:  MultiXact member wraparound protections are now enabled
postgres_1  | LOG:  database system is ready to accept connections
postgres_1  | LOG:  autovacuum launcher started
app_1       | Operations to perform:
app_1       |   Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, secrets, sessions, taggit, tenancy, users, virtualization
app_1       | Running migrations:
app_1       |   Applying dcim.0058_relax_rack_naming_constraints...Traceback (most recent call last):
app_1       |   File "./manage.py", line 10, in <module>
app_1       |     execute_from_command_line(sys.argv)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
app_1       |     utility.execute()
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
app_1       |     self.fetch_command(subcommand).run_from_argv(self.argv)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
app_1       |     self.execute(*args, **cmd_options)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
app_1       |     output = self.handle(*args, **options)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 200, in handle
app_1       |     fake_initial=fake_initial,
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 117, in migrate
app_1       |     state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
app_1       |     state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
app_1       |     state = migration.apply(state, schema_editor)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/db/migrations/migration.py", line 122, in apply
app_1       |     operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/db/migrations/operations/models.py", line 525, in database_forwards
app_1       |     getattr(new_model._meta, self.option_name, set()),
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 358, in alter_unique_together
app_1       |     self._delete_composed_index(model, fields, {'unique': True}, self.sql_delete_unique)
app_1       |   File "/usr/local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 387, in _delete_composed_index
app_1       |     ", ".join(columns),
app_1       | ValueError: Found wrong number (2) of constraints for dcim_rack(site_id, facility_id)
app_1       | ⏳ Waiting on DB...
^CGracefully stopping... (press Ctrl+C again to force)
Stopping netbox_nginx_1    ... done
Stopping netbox_app_1      ... done
Stopping netbox_postgres_1 ... done

Thanks!

Matthew Yauch

unread,
Aug 13, 2018, 11:11:06 AM8/13/18
to NetBox
The plot thickens...

I set my branch back to v2.3.4 and it starts up fine.  I'm going to incrementally upgrade each version and see what happens.

Matthew Yauch

unread,
Aug 13, 2018, 12:28:56 PM8/13/18
to NetBox
OK here were my results.
v2.3.4 starts up, received an error when browsing just about anything, probably due to newer information in the database that the older version can't understand.
    <class 'TypeError'>
    __init__() got an unexpected keyword argument 'name'
v2.3.5 starts up, same error as v2.3.4
v2.3.6 starts up, can browse all of my data no problems.
v2.3.7 now starts up after incrementally moving from version to version.  No issues browsing.
v2.4.0 is back to the ValueError.
    app_1       | ValueError: Found wrong number (2) of constraints for dcim_rack(site_id, facility_id)
And amazingly v2.3.7 is back to this error.  I just realized that even when I use an older version of data it's still using the same v.2.4.0 built image, even though I made a change in my docker-compose.yml, so it's really just v2.4.0 causing the issue.

Removed the v2.4.0 image layers:
docker image prune -a
Rebuilt v2.3.7
docker-compose build
Restarted v2.3.7
docker-compose up -d

Back up and running on v2.3.7 without issue.  My conclusion is something is going horribly wrong trying to upgrade to v2.4.0+.

Brian Candler

unread,
Aug 14, 2018, 2:55:28 AM8/14/18
to NetBox
What version of Postgres are you using?

Matthew Yauch

unread,
Aug 14, 2018, 11:20:01 AM8/14/18
to NetBox
I'm using the postgres:9.6-alpine Docker image.

Reply all
Reply to author
Forward
0 new messages