HI,

I'm having a strange behavior with a SD. When trying to manage the SD I see they "Add" button for the LUN which should already be the one use for that SD.
In the Logs I see the following:

2020-07-13 17:48:07,292+02 ERROR [org.ovirt.engine.core.dal.dbbroker.BatchProcedureExecutionConnectionCallback] (EE-ManagedThreadFactory-engine-Thread-95) [51091853] Can't execute batch: Batch entry 0 select * from public.insertluns(CAST ('repl_HanaLogs_osd_01' AS varchar),CAST ('DPUtaW-Q5zp-aZos-HriP-5Z0v-hiWO-w7rmwG' AS varchar),CAST ('4TCXZ7-R1l1-xkdU-u0vx-S3n4-JWcE-qksPd1' AS varchar),CAST ('SHUAWEI_XSG1_2102350RMG10HC0000200035' AS varchar),CAST (7 AS int4),CAST ('HUAWEI' AS varchar),CAST ('XSG1' AS varchar),CAST (2548 AS int4),CAST (268435456 AS int8)) as result was aborted: ERROR: duplicate key value violates unique constraint "pk_luns"
  Detail: Key (lun_id)=(repl_HanaLogs_osd_01) already exists.
  Where: SQL statement "INSERT INTO LUNs (
        LUN_id,
        physical_volume_id,
        volume_group_id,
        serial,
        lun_mapping,
        vendor_id,
        product_id,
        device_size,
        discard_max_size
        )
    VALUES (
        v_LUN_id,
        v_physical_volume_id,
        v_volume_group_id,
        v_serial,
        v_lun_mapping,
        v_vendor_id,
        v_product_id,
        v_device_size,
        v_discard_max_size
        )"
PL/pgSQL function insertluns(character varying,character varying,character varying,character varying,integer,character varying,character varying,integer,bigint) line 3 at SQL statement  Call getNextException to see other errors in the batch.
2020-07-13 17:48:07,292+02 ERROR [org.ovirt.engine.core.dal.dbbroker.BatchProcedureExecutionConnectionCallback] (EE-ManagedThreadFactory-engine-Thread-95) [51091853] Can't execute batch. Next exception is: ERROR: duplicate key value violates unique constraint "pk_luns"
  Detail: Key (lun_id)=(repl_HanaLogs_osd_01) already exists.
  Where: SQL statement "INSERT INTO LUNs (
        LUN_id,
        physical_volume_id,
        volume_group_id,
        serial,
        lun_mapping,
        vendor_id,
        product_id,
        device_size,
        discard_max_size
        )
    VALUES (
        v_LUN_id,
        v_physical_volume_id,
        v_volume_group_id,
        v_serial,
        v_lun_mapping,
        v_vendor_id,
        v_product_id,
        v_device_size,
        v_discard_max_size
        )"
PL/pgSQL function insertluns(character varying,character varying,character varying,character varying,integer,character varying,character varying,integer,bigint) line 3 at SQL statement
2020-07-13 17:48:07,293+02 INFO  [org.ovirt.engine.core.utils.transaction.TransactionSupport] (EE-ManagedThreadFactory-engine-Thread-95) [51091853] transaction rolled back
2020-07-13 17:48:07,293+02 ERROR [org.ovirt.engine.core.bll.storage.domain.SyncLunsInfoForBlockStorageDomainCommand] (EE-ManagedThreadFactory-engine-Thread-95) [51091853] Command 'org.ovirt.engine.core.bll.storage.domain.SyncLunsInfoForBlockStorageDomainCommand' failed: ConnectionCallback; ]; ERROR: duplicate key value violates unique constraint "pk_luns"
  Detail: Key (lun_id)=(repl_HanaLogs_osd_01) already exists.
  Where: SQL statement "INSERT INTO LUNs (
        LUN_id,
        physical_volume_id,
        volume_group_id,
        serial,
        lun_mapping,
        vendor_id,
        product_id,
        device_size,
        discard_max_size
        )
    VALUES (
        v_LUN_id,
        v_physical_volume_id,
        v_volume_group_id,
        v_serial,
        v_lun_mapping,
        v_vendor_id,
        v_product_id,
        v_device_size,
        v_discard_max_size
        )"

It looks like the engine will add a LUN to an SD and it already exist...
Any Idea how to resolve that problem?

Thanks a lot


-- 
Arsène Gschwind <arsene.gschwind@unibas.ch>
Universitaet Basel