RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1737790 - improve error message "error: internal error: Duplicate key"
Summary: improve error message "error: internal error: Duplicate key"
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: libvirt
Version: 8.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Ján Tomko
QA Contact: chhu
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-08-06 08:52 UTC by yafu
Modified: 2020-11-14 09:52 UTC (History)
5 users (show)

Fixed In Version: libvirt-4.5.0-32.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-05 20:51:11 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2019:3345 0 None None None 2019-11-05 20:51:39 UTC

Description yafu 2019-08-06 08:52:05 UTC
Description of problem:
When trying to define a guest while the guest is removing, incorrect error message report:
"error: internal error: Duplicate key"

Version-Release number of selected component (if applicable):
libvirt-4.5.0-31.module+el8.1.0+3808+3325c1a3.x86_64

How reproducible:
100%


Steps to Reproduce:
1.# virsh create vm1.xml; virsh destroy vm1& virsh define vm1.xml;sleep 1; virsh undefine vm1;
Domain vm1 created from vm1.xml

[1] 26608
Domain vm1 destroyed
error: 
Failed to define domain from vm1.xml
error: internal error: Duplicate key

[1]+  Done                    virsh destroy vm1
error: failed to get domain 'vm1'
error: Domain not found: no domain with matching name 'vm1'

Actual results:
The error info is not helpful.

Expected results:
Improve the error message.


Additional info:

Comment 1 Ján Tomko 2019-08-06 10:55:36 UTC
Fixed upstream by:
commit a5c71129bf2c12a827f1bc00149acd1c572ffe9c
Author:     Michal Privoznik <mprivozn>
CommitDate: 2019-04-04 09:16:24 +0200

    virDomainObjListAddLocked: Produce better error message than 'Duplicate key'
    
    If there are two concurrent threads, one of which is removing a
    domain from the list and the other is trying to add it back they
    may serialize in the following order:
    
    1) vm->removing is set and @vm is unlocked.
    2) The tread that's trying to add the domain onto the list locks
       the list and tries to find, if the domain already exists.
    3) Our lookup functions say it doesn't, so the thread proceeds to
       virHashAddEntry() which fails with 'Duplicate key' error.
    
    This is obviously not helpful error message at all.
    
    The problem lies in our lookup functions
    (virDomainObjListFindByUUIDLocked() and
    virDomainObjListFindByNameLocked()) which return NULL even if the
    object is still on the list. They do this so that the object is
    not mistakenly looked up by some driver. The fix consists of
    moving 'removing' check one level up and thus allowing
    virDomainObjListAddLocked() to produce meaningful error message.
    
    Signed-off-by: Michal Privoznik <mprivozn>
    Reviewed-by: Cole Robinson <crobinso>

git describe: v5.2.0-114-ga5c71129bf contains: v5.3.0-rc1~253

Comment 4 chhu 2019-08-28 03:45:55 UTC
Verified on packages:
libvirt-4.5.0-33.module+el8.1.0+4066+0f1aadab.x86_64

Get error messge:"error: operation failed: domain 'r8' is already being removed"
other than "error: internal error: Duplicate key". Set the bug status as "Verified"
Rerun 10 times, virsh command work well, libvirtd service work well.

Set the bug status to "VERIFIED".

Test steps:
# virsh create r8-1.xml; virsh destroy r8& virsh define r8-1.xml; sleep 1; virsh undefine r8
Domain r8 created from r8-1.xml

[1] 14440
Domain r8 destroyed
error: Failed to define domain from r8-1.xml
error: operation failed: domain 'r8' is already being removed
[1]+  Done                    virsh destroy r8
error: failed to get domain 'r8'
error: Domain not found: no domain with matching name 'r8'

# virsh list --all
 Id    Name                           State
----------------------------------------------------

Comment 6 errata-xmlrpc 2019-11-05 20:51:11 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2019:3345


Note You need to log in before you can comment on or make changes to this bug.