Bug 1173251 - SCVMM error when saving a vm or template [ActiveRecord::RecordNotUnique]
Summary: SCVMM error when saving a vm or template [ActiveRecord::RecordNotUnique]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Insight
Version: 5.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: GA
: 5.4.0
Assignee: Bronagh Sorota
QA Contact: Milan Falešník
URL:
Whiteboard:
Depends On:
Blocks: 1178976
TreeView+ depends on / blocked
 
Reported: 2014-12-11 18:28 UTC by Bronagh Sorota
Modified: 2015-06-16 12:46 UTC (History)
3 users (show)

Fixed In Version: 5.4.0.0.11
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1178976 (view as bug list)
Environment:
Last Closed: 2015-06-16 12:46:19 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1100 0 normal SHIPPED_LIVE CFME 5.4.0 bug fixes, and enhancement update 2015-06-16 16:28:42 UTC

Description Bronagh Sorota 2014-12-11 18:28:26 UTC
Description of problem:

In a Red Hat lab used by field engineering we are seeing a Postgres error that makes no sense. The error indicates a duplicate row is being inserted into the table storages_vms_and_templates, when the table is empty and only 1 VM exists.



Version-Release number of selected component (if applicable):


How reproducible:



Steps to Reproduce:
1. reset database to ensure it is empty
2. to keep things simple i limited the VM inventory to 1 VM.
3. Add SCVMM provider


Actual results:

Worker bombs out with this error:
[----] E, [2014-12-11T18:16:54.849551 #12178:3ffcde0349d4] ERROR -- : MIQ(abstract_adapter) Name: [], Message: [PGError: ERROR:  duplicate key value violates unique constraint "index_storages_vms_on_vm_id_and_storage_id"
DETAIL:  Key (vm_or_template_id, storage_id)=(1, 2) already exists.
: INSERT INTO "storages_vms_and_templates" ("vm_or_template_id", "storage_id") VALUES (1, 2)]
[----] E, [2014-12-11T18:16:54.851814 #12178:3ffcde0349d4] ERROR -- : MIQ(EmsRefresh.save_vms_inventory) EMS: [System Center Virtual Machine Manager 2012 R2], id: [1] Processing Vm: [scvmm] failed with error [PGError: ERROR:  duplicate key value violates unique constraint "index_storages_vms_on_vm_id_and_storage_id"
DETAIL:  Key (vm_or_template_id, storage_id)=(1, 2) already exists.
: INSERT INTO "storages_vms_and_templates" ("vm_or_template_id", "storage_id") VALUES (1, 2)]. Skipping Vm.
[----] E, [2014-12-11T18:16:54.852007 #12178:3ffcde0349d4] ERROR -- : [ActiveRecord::RecordNotUnique]: PGError: ERROR:  duplicate key value violates unique constraint "index_storages_vms_on_vm_id_and_storage_id"
DETAIL:  Key (vm_or_template_id, storage_id)=(1, 2) already exists.
: INSERT INTO "storages_vms_and_templates" ("vm_or_template_id", "storage_id") VALUES (1, 2)  Method:[rescue in block in save_vms_inventory]
[----] E, [2014-12-11T18:16:54.852089 #12178:3ffcde0349d4] ERROR -- : /Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:1346:in `async_exec'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:1346:in `block in exec_no_cache'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:1284:in `with_auto_reconnect'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:1345:in `exec_no_cache'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:736:in `block in exec_query'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:287:in `block in log'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:282:in `log'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:735:in `exec_query'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:63:in `exec_insert'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb:29:in `insert_record'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/autosave_association.rb:350:in `block in save_collection_association'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/autosave_association.rb:341:in `each'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/autosave_association.rb:341:in `save_collection_association'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/autosave_association.rb:191:in `block in add_autosave_association_callbacks'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/autosave_association.rb:161:in `instance_eval'
/Users/bronaghsorota/.rvm/gems/ruby-1.9.3-p484/bundler/gems/rails-cab310aeee22/activerecord/lib/active_record/autosave_association.rb:161:in `block in define_non_cyclic_m

Expected results:


Additional info:

Comment 2 CFME Bot 2014-12-17 17:06:12 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/a2b4c37f1e3b27a1cf30091ebda2ff930c863dcb

commit a2b4c37f1e3b27a1cf30091ebda2ff930c863dcb
Author:     Bronagh Sorota <bsorota>
AuthorDate: Mon Dec 15 14:09:03 2014 -0500
Commit:     Bronagh Sorota <bsorota>
CommitDate: Wed Dec 17 07:11:52 2014 -0500

    SCVMM - DB error VM with multiple VHDs on volume
    
    Make sure the VM's storages hash does not contain duplicates.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1173251

 vmdb/app/models/ems_refresh/parsers/scvmm.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comment 3 Milan Falešník 2015-03-05 15:38:51 UTC
Verified in 5.4.0.0.10, same as in BZ#1178976.

Comment 6 errata-xmlrpc 2015-06-16 12:46:19 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://rhn.redhat.com/errata/RHBA-2015-1100.html


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