duplicate key value violates unique constraint "storageadmin_disk_name_key"DETAIL: Key (name)=(usb-KODAK_SS_D_X200_1TB_012345679219-0:0) already exists.

Brief description of the problem

Trying to use two USB HDD devices of the same type but different SN results in an error. I can use one disk or the other, but not both despite them having different S:N

Detailed step by step instructions to reproduce the problem

Add disk one - works fine. Add disk two - get error when attempting a rescan

Web-UI screenshot

Error Traceback provided on the Web-UI

        Traceback (most recent call last):

File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/backends/utils.py”, line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/cursor.py”, line 97, in execute
raise ex.with_traceback(None)
psycopg.errors.UniqueViolation: duplicate key value violates unique constraint “storageadmin_disk_name_key”
DETAIL: Key (name)=(usb-KODAK_SS_D_X200_1TB_012345679219-0:0) already exists.

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/disk.py”, line 417, in post
return self._update_disk_state()
^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/lib64/python3.11/contextlib.py”, line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/src/rockstor/storageadmin/views/disk.py”, line 177, in _update_disk_state
dob.save(update_fields=[“name”])
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/models/base.py”, line 814, in save
self.save_base(
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/models/base.py”, line 877, in save_base
updated = self._save_table(
^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/models/base.py”, line 990, in _save_table
updated = self._do_update(
^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/models/base.py”, line 1054, in _do_update
return filtered._update(values) > 0
^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/models/query.py”, line 1231, in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/models/sql/compiler.py”, line 1984, in execute_sql
cursor = super().execute_sql(result_type)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/models/sql/compiler.py”, line 1562, in execute_sql
cursor.execute(sql, params)
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/backends/utils.py”, line 67, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/backends/utils.py”, line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/django/db/backends/utils.py”, line 84, in _execute
with self.db.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/utils.py”, line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/opt/rockstor/.venv/lib/python3.11/site-packages/psycopg/cursor.py”, line 97, in execute
raise ex.with_traceback(None)
django.db.utils.IntegrityError: duplicate key value violates unique constraint “storageadmin_disk_name_key”
DETAIL: Key (name)=(usb-KODAK_SS_D_X200_1TB_012345679219-0:0) already exists.

@Mithias_uk welcome to the Rockstor community.

  • Which version of Rockstor are you running?
  • Are you using an USB enclosure (multi-bay) to connect these drives?
2 Likes

If you have access to the command line (via built-in WebUI or remote terminal access like PuTTY) can you run this command to get some more details on these drives and how they’re presented to Rockstor?

lsblk -P -p -o NAME,MODEL,SERIAL,SIZE,TRAN,VENDOR,HCTL,TYPE,FSTYPE,LABEL,UUID
2 Likes