Insert or update on table "storageadmin_networkdevice" violates foreign key constraint "storageadmin_network_connection_id_6a520cbf_fk_storagead"DETAIL: Key (connection_id)=(39) is not present in table "storageadmin_networkconnection"

Hi All… Have not been on in a while and I am once again asking for help.

I have 2 separate boxes and both of them are getting the below error when I open the System/Network screen in the dashboard GUI. (not sure what the right name is for this GUI?)

        Traceback (most recent call last):

File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/backends/base/base.py”, line 312, in _commit
return self.connection.commit()
^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/connection.py”, line 262, in commit
self.wait(self._commit_gen())
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/connection.py”, line 414, in wait
return waiting.wait(gen, self.pgconn.socket, interval=interval)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/waiting.py”, line 354, in wait_poll
s = gen.send(ready)
^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/_connection_base.py”, line 580, in _commit_gen
yield from self._exec_command(b"COMMIT")
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/_connection_base.py”, line 478, in _exec_command
raise e.error_from_result(result, encoding=self.pgconn._encoding)
psycopg.errors.ForeignKeyViolation: insert or update on table “storageadmin_networkdevice” violates foreign key constraint “storageadmin_network_connection_id_6a520cbf_fk_storagead”
DETAIL: Key (connection_id)=(39) is not present in table “storageadmin_networkconnection”.

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

Traceback (most recent call last):
File “/opt/rockstor/src/rockstor/rest_framework_custom/generic_view.py”, line 40, in _handle_exception
yield
File “/opt/rockstor/src/rockstor/storageadmin/views/network.py”, line 235, in get_queryset
self._refresh_devices()
File “/usr/lib64/python3.11/contextlib.py”, line 80, in inner
with self._recreate_cm():
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/transaction.py”, line 263, in exit
connection.commit()
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/utils/asyncio.py”, line 26, in inner
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/backends/base/base.py”, line 336, in commit
self._commit()
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/backends/base/base.py”, line 311, in _commit
with debug_transaction(self, “COMMIT”), self.wrap_database_errors:
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/utils.py”, line 91, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/backends/base/base.py”, line 312, in _commit
return self.connection.commit()
^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/connection.py”, line 262, in commit
self.wait(self._commit_gen())
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/connection.py”, line 414, in wait
return waiting.wait(gen, self.pgconn.socket, interval=interval)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/waiting.py”, line 354, in wait_poll
s = gen.send(ready)
^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/_connection_base.py”, line 580, in _commit_gen
yield from self._exec_command(b"COMMIT")
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/_connection_base.py”, line 478, in _exec_command
raise e.error_from_result(result, encoding=self.pgconn._encoding)
django.db.utils.IntegrityError: insert or update on table “storageadmin_networkdevice” violates foreign key constraint “storageadmin_network_connection_id_6a520cbf_fk_storagead”
DETAIL: Key (connection_id)=(39) is not present in table “storageadmin_networkconnection”.

UPDATE* When I refreshed my browser (Firefox) the error went away.

1 Like

Curious that a browser refresh would resolve this. There is some front/back-end work to be done now that 5.1 is out, since the current front-end implementation is very old.

Was this going straight from after logging in and starting out at the dashboard? Or did you anything else in between (like this screen had been sitting there for some time when you returned to it)?

I assume, you didn’t make a recent change to your network connections that just hadn’t synchronized in the UI yet, either?

As you can tell, I’m fishing in the dark here for now :slight_smile:

2 Likes