Bug 1220361 - PL/SQL rhn_entitlements.repoll_virt_guest_entitlements() is throwing the error "ERROR: LIMIT must not be negative"
Summary: PL/SQL rhn_entitlements.repoll_virt_guest_entitlements() is throwing the erro...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Spacewalk
Classification: Community
Component: Server
Version: 2.3
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Grant Gainey
QA Contact: Red Hat Satellite QA List
URL:
Whiteboard:
Depends On: 1210011
Blocks: 465198 sat570-triage 1214484 space24
TreeView+ depends on / blocked
 
Reported: 2015-05-11 12:06 UTC by Grant Gainey
Modified: 2015-10-08 13:26 UTC (History)
5 users (show)

Fixed In Version: spacewalk-schema-2.4.7-1
Doc Type: Bug Fix
Doc Text:
Clone Of: 1210011
Environment:
Last Closed: 2015-10-08 13:26:48 UTC
Embargoed:


Attachments (Terms of Use)

Description Grant Gainey 2015-05-11 12:06:33 UTC
+++ This bug was initially created as a clone of Bug #1210011 +++

Description of problem:
 
  Receiving traceback emails with the error below:

+++++++
SQL Error generated: (99999, 'ERROR:  current transaction is aborted, commands ignored until end of transaction block', '', InternalError('current transaction is aborted, commands ignored until end of transaction block\n',))

Exception Handler Information
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/spacewalk/server/apacheRequest.py", line 122, in call_function
    response = func(*params)
  File "/usr/share/rhn/server/handlers/xmlrpc/registration.py", line 913, in virt_notify
    rhnVirtualization._virt_notify(server_id, actions)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnVirtualization.py", line 806, in _virt_notify
    handler.handle(server_id, action)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnVirtualization.py", line 211, in handle
    handler(system_id, timestamp, properties)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnVirtualization.py", line 241, in _handle_domain_exists
    row = self.__db_get_domain(system_id, uuid)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnVirtualization.py", line 513, in __db_get_domain
    query.execute(host_id = host_id, uuid = uuid)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 147, in execute
    return self._execute_wrapper(self._execute, *p, **kw)
  File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 292, in _execute_wrapper
    raise sql_base.SQLSchemaError(error_code, e.pgerror, e)
SQLSchemaError: (99999, 'ERROR:  current transaction is aborted, commands ignored until end of transaction block', '', InternalError('current transaction is aborted, commands ignored until end of transaction block\n',))
+++++++

  Looking at the database logs, we can see the PL/SQL error:

2015-03-10 23:44:02.343 EDT ERROR:  LIMIT must not be negative
2015-03-10 23:44:02.343 EDT CONTEXT:  SQL statement "UPDATE rhnServerChannel sc set is_fve = 'Y'
                        where sc.server_id in (
                                    select vi.virtual_system_id
                                    from rhnServerFveCapable sfc
                                        inner join rhnVirtualInstance vi on vi.virtual_system_id = sfc.server_id
                                    where vi.host_system_id = server_id_in
                                          and sfc.channel_family_id = family.channel_family_id
                                      order by vi.modified desc
                                    limit free_slots
                        )"
                        
        PL/pgSQL function rhn_entitlements.repoll_virt_guest_entitlements(numeric) line 102 at SQL statement

2015-03-10 23:44:02.343 EDT STATEMENT:  SELECT rhn_entitlements.repoll_virt_guest_entitlements(1000020471)
2015-03-10 23:44:02.345 EDT ERROR:  current transaction is aborted, commands ignored until end of transaction block


   We know that the virt/virt-platform are deprecated, however after asking the customer database to do some investigation, we were able to address this problem after cutting a Satellite entitlement certificate with some virt and virt-platform entitlements. 

   Looking on the top of this PL, the SQL test verifies if it system has a virtualization platform or not:

++++++
    begin
           select 1 into is_virt
                 from rhnServerEntitlementView
            where server_id = server_id_in
                  and label in ('virtualization_host', 'virtualization_host_platform');
++++++

   However looking at the RHEV hosts registered, they don't have the virtualization_host_platform entitlement

   Before assigning to the virtualization platform to the RHEV host, this was the error:

rhnschema=# select rhn_entitlements.repoll_virt_guest_entitlements(1000020471);
ERROR:  LIMIT must not be negative
CONTEXT:  SQL statement "UPDATE rhnServerChannel sc set is_fve = 'Y'
                where sc.server_id in (
                            select vi.virtual_system_id
                            from rhnServerFveCapable sfc
                                inner join rhnVirtualInstance vi on vi.virtual_system_id = sfc.server_id
                            where vi.host_system_id = server_id_in
                                  and sfc.channel_family_id = family.channel_family_id
                              order by vi.modified desc
                            limit free_slots
                )"
PL/pgSQL function rhn_entitlements.repoll_virt_guest_entitlements(numeric) line 102 at SQL statement

 
   After assign it:

  rhnschema=# select rhn_entitlements.repoll_virt_guest_entitlements(1000020471);
ERROR:  can't read "the_log_id": no such variable
CONTEXT:  can't read "the_log_id": no such variable
    while executing
"return $the_log_id"
    (procedure "__PLTcl_proc_16459" line 4)
    invoked from within
"__PLTcl_proc_16459"
in PL/Tcl function "_get_log_id"
PL/pgSQL function get_log_id() line 7 at assignment
PL/pgSQL function rhnservergroup_log_trig_fun() line 5 at assignment
SQL statement "update rhnServerGroup set current_members = current_members_calc
           where org_id = a_group_type.org_id
             and group_type = a_group_type.group_type"
PL/pgSQL function rhn_entitlements.repoll_virt_guest_entitlements(numeric) line 218 at SQL statement

  ** Disabling audit rules  

rhnschema=# select * from  logging.clear_log_id();
 clear_log_id 
--------------
 
(1 row)

            
rhnschema=# select rhn_entitlements.repoll_virt_guest_entitlements(1000020471);
 repoll_virt_guest_entitlements 
--------------------------------
 
(1 row)


 -- testing another servers

  rhnschema=# select * from  logging.clear_log_id();
 clear_log_id 
--------------
 
(1 row)

rhnschema=# select rhn_entitlements.repoll_virt_guest_entitlements(1000020472);
ERROR:  LIMIT must not be negative
CONTEXT:  SQL statement "UPDATE rhnServerChannel sc set is_fve = 'Y'
                where sc.server_id in (
                            select vi.virtual_system_id
                            from rhnServerFveCapable sfc
                                inner join rhnVirtualInstance vi on vi.virtual_system_id = sfc.server_id
                            where vi.host_system_id = server_id_in
                                  and sfc.channel_family_id = family.channel_family_id
                              order by vi.modified desc
                            limit free_slots
                )"
PL/pgSQL function rhn_entitlements.repoll_virt_guest_entitlements(numeric) line 102 at SQL statement

 adding entitlement 
---
rhnschema=# select rhn_entitlements.repoll_virt_guest_entitlements(1000020472);
 repoll_virt_guest_entitlements 
--------------------------------
 
(1 row)


Version-Release number of selected component (if applicable):
spacewalk-java-2.3.8-100.el6sat.noarch

Actual results:

 SQL throws the error and traceback error


Expected results:

 It should work as expected or the SQL should not consider the virt/virt-platforom since its deprecated

Comment 1 Grant Gainey 2015-05-11 12:11:19 UTC
spacewalk.github commit a98940c4bb9c2eea387b8c16371133eb7d7787a4

Comment 2 Grant Gainey 2015-05-12 13:34:33 UTC
spacewalk.github commit a334c750612aa5c3cf0c16a21a9233f1a188cb85

Comment 3 Jan Dobes 2015-10-08 13:26:48 UTC
Spacewalk 2.4 has been released.


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