Bug 2095215

Summary: Uploading disk with same ID causes sql errors and locked disk
Product: [oVirt] ovirt-engine Reporter: Jean-Louis Dupond <jean-louis>
Component: BLL.StorageAssignee: Artiom Divak <adivak>
Status: CLOSED CURRENTRELEASE QA Contact: Ilia Markelov <imarkelo>
Severity: high Docs Contact:
Priority: unspecified    
Version: 4.5.0.8CC: ahadas, bugs, bzlotnik, dfodor, jean-louis, sfishbai
Target Milestone: ovirt-4.5.2Flags: pm-rhel: ovirt-4.5?
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-4.5.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-30 08:47:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jean-Louis Dupond 2022-06-09 10:13:46 UTC
Upload a disk via the python tools:
$ ./upload_disk.py -c OV --disk-format raw --sd-name STORAGE 6914eec5-6e89-46ad-aa44-e545de7e296b.1b60a0c1-76e9-4cdc-ab67-a1af8430cf2f.202
206021456.full.qcow2 
[  0.0 ] Checking image... 
[  0.0 ] Image format: qcow2 
[  0.0 ] Disk format: raw 
[  0.0 ] Disk content type: data 
[  0.0 ] Disk provisioned size: 2147483648 
[  0.0 ] Disk initial size: 2147483648 
[  0.0 ] Disk name: 6914eec5-6e89-46ad-aa44-e545de7e296b.1b60a0c1-76e9-4cdc-ab67-a1af8430cf2f.202206021456.full.raw 
[  0.0 ] Disk backup: False 
[  0.0 ] Connecting... 
[  0.0 ] Creating disk... 
[ 16.4 ] Disk ID: 33396852-743f-46e2-bcc4-013b04ec9b2a 
[ 16.4 ] Creating image transfer... 
[ 18.1 ] Transfer ID: 1199d383-8eb9-4e95-bc14-31f6551fe25b 
[ 18.1 ] Transfer host name: xxxxxx 
[ 18.1 ] Uploading image... 
[ 100.00% ] 2.00 GiB, 2.88 seconds, 711.54 MiB/s                               
[ 21.0 ] Finalizing image transfer... 
[ 23.0 ] Upload completed successfully 

And then uploading the disk with the disk-id specified (as displayed above)

$ ./upload_disk.py -c OV --disk-format raw --disk-id 33396852-743f-46e2-bcc4-013b04ec9b2a --sd-name STORAGE 6914eec5-6e89-46ad-aa44-e545de
7e296b.c50753d4-9897-42d5-be5b-c7c58325e0d3.202206021534.diff.qcow2 
[  0.0 ] Checking image... 
[  0.0 ] Image format: qcow2 
[  0.0 ] Disk format: raw 
[  0.0 ] Disk content type: data 
[  0.0 ] Disk provisioned size: 2147483648 
[  0.0 ] Disk initial size: 2147483648 
[  0.0 ] Disk name: 6914eec5-6e89-46ad-aa44-e545de7e296b.c50753d4-9897-42d5-be5b-c7c58325e0d3.202206021534.diff.raw 
[  0.0 ] Disk backup: False 
[  0.0 ] Connecting... 
[  0.0 ] Creating disk... 
Traceback (most recent call last): 

This causes the following error in oVirt:
2022-06-09 11:34:07,033+02 ERROR [org.ovirt.engine.core.bll.storage.disk.AddDiskCommand] (default task-303) [6aacac59-b539-480d-b43f-23d068408496] Command 'org.ovirt.engine.core.bll.storage.disk.AddDiskCommand' failed: CallableStatementCallback; SQL [{call insertpermission(?, ?, ?, ?, ?)}ERROR: duplicate key value violates unique constraint "idx_combined_ad_role_object"
  Detail: Key (ad_element_id, role_id, object_id)=(7740299e-9b9c-11ec-b93c-00505697d7a8, def0000a-0000-0000-0000-def00000000b, 33396852-743f-46e2-bcc4-013b04ec9b2a) already exists.
  Where: SQL statement "INSERT INTO permissions (
        ad_element_id,
        id,
        role_id,
        object_id,
        object_type_id
        )
    VALUES (
        v_ad_element_id,
        v_id,
        v_role_id,
        v_object_id,
        v_object_type_id
        )"
PL/pgSQL function insertpermission(uuid,uuid,uuid,uuid,integer) line 3 at SQL statement; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "idx_combined_ad_role_object"


And resulting in a failed disk creation + a locked image.

This should have been resolved by https://gerrit.ovirt.org/c/ovirt-engine/+/114134/
But it seems like the check is not complete enough here :)

Comment 1 RHEL Program Management 2022-06-09 13:25:43 UTC
The documentation text flag should only be set after 'doc text' field is provided. Please provide the documentation text and set the flag to '?' again.

Comment 2 Arik 2022-06-09 14:49:27 UTC
What is the type of the storage domain you upload the image to?

Comment 3 Jean-Louis Dupond 2022-06-09 15:29:37 UTC
Storage domain is a DATA/iSCSI domain

Comment 4 Arik 2022-06-13 14:21:21 UTC
Seems like we validate the uniqueness of the image-id but not that of the image-group-id (disk id), need to add a similar validation then

Comment 5 Ilia Markelov 2022-07-25 12:22:48 UTC
Verified.

Operation fails with a proper error:
2022-07-25 15:04:25,280+03 ERROR [org.ovirt.engine.api.restapi.resource.AbstractBackendResource] (default task-13) [] Operation Failed: [Cannot add Virtual Disk. The selected disk ID: <disk-id> is already used by the following existing disk: <disk-name>.]

Versions:
engine-4.5.2-0.3.el8ev.noarch
vdsm-4.50.2.1-1.el8ev.x86_64

Comment 6 Sandro Bonazzola 2022-08-30 08:47:42 UTC
This bugzilla is included in oVirt 4.5.2 release, published on August 10th 2022.
Since the problem described in this bug report should be resolved in oVirt 4.5.2 release, it has been closed with a resolution of CURRENT RELEASE.
If the solution does not work for you, please open a new bug report.