Bug 1126499

Summary: ISE 500 when systems were converted from regular entitlements to flex
Product: Red Hat Satellite 5 Reporter: Pavel Studeník <pstudeni>
Component: ServerAssignee: Grant Gainey <ggainey>
Status: CLOSED ERRATA QA Contact: Ales Dujicek <adujicek>
Severity: high Docs Contact:
Priority: high    
Version: 570CC: adujicek, ggainey
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spacewalk-java-2.3.8-149-sat Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1252560 (view as bug list) Environment:
Last Closed: 2016-08-22 12:23:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 924189, 1252560    
Attachments:
Description Flags
If you're going to commitTxact, need to reset log-id none

Description Pavel Studeník 2014-08-04 15:22:01 UTC
Description of problem:
I get Internal Server Error when I try to convert systems with Regular entitlements to Flex. Problem is only when I convert more then 1 systems. When I choose only one system, I doesn't get any errors. Two scenarios with incorrect functionality:

1) choose 2 systems and flex entitlements is unavailable: got ISE and without effect on this systems
2) choose 2 systems and flex entitlements is available: only first systems was changed

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

How reproducible:
always 

Steps to Reproduce:
1. create some virtual guests on KVM/Xen/VMware
2. create organization with only available regular entitlements (without available flex entitlements)
3. register systems to this organization 
4. try to go on /rhn/systems/entitlements/EligibleFlexGuests.do 
5. choose more then 1 systems to convert (click "Convert To Flex Guest Entitlement")

Actual results:
I got Internal Server Error

Expected results:
without ISE 500, but show messages about unavailable flex entitlements


Additional info:
>> tail -f /var/log/tomcat6/catalina.out
Aug 4, 2014 10:35:07 AM com.mchange.v2.c3p0.impl.NewPooledConnection handleThrowable
WARNING: [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
Aug 4, 2014 10:35:07 AM com.mchange.v2.c3p0.impl.NewPooledConnection handleThrowable
WARNING: [c3p0] Another error has occurred [ org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block ] which will not be reported to listeners!
Throwable occurred: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:360)
	at com.mchange.v2.c3p0.impl.NewProxyCallableStatement.execute(NewProxyCallableStatement.java:2706)
	at com.redhat.rhn.common.db.NamedPreparedStatement.execute(NamedPreparedStatement.java:117)
	at com.redhat.rhn.common.db.datasource.CachedStatement.executeCallable(CachedStatement.java:528)
	at com.redhat.rhn.common.db.datasource.CallableMode.execute(CallableMode.java:35)
	at com.redhat.rhn.common.hibernate.HibernateFactory.executeCallableMode(HibernateFactory.java:605)
	at com.redhat.rhn.domain.common.LoggingFactory.clearLogId(LoggingFactory.java:49)
	at com.redhat.rhn.frontend.servlets.SessionFilter.doFilter(SessionFilter.java:95)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at com.redhat.rhn.frontend.servlets.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:97)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
	at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
	at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
	at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
	at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
	at java.lang.Thread.run(Thread.java:761)

Comment 3 Grant Gainey 2016-07-11 15:08:22 UTC
From /opt/rh/postgresql92/root/var/lib/pgsql/data/pg_log/postgresql-<day>.log :

2016-07-11 10:54:02.642 EDT ERROR:  -20296 : (not_enough_flex_entitlements) - You do not have enough entitlements in your org..
2016-07-11 10:54:02.642 EDT CONTEXT:  SQL statement "SELECT rhn_exception.raise_exception('not_enough_flex_entitlements')"
        PL/pgSQL function rhn_channel.convert_to_fve(numeric,numeric) line 48 at PERFORM
2016-07-11 10:54:02.642 EDT STATEMENT:  select * from rhn_channel.convert_to_fve($1, $2)  as result
2016-07-11 10:54:02.692 EDT ERROR:  current transaction is aborted, commands ignored until end of transaction block
2016-07-11 10:54:02.692 EDT STATEMENT:  select 'c3p0 ping' from dual

Comment 4 Grant Gainey 2016-07-11 18:55:37 UTC
Created attachment 1178508 [details]
If you're going to commitTxact, need to reset log-id

The convert-to-flex path commits after every system. With the addition of audit-logging, we need to insure the audit-log-user and log_id get reset in the new transaction.

Comment 12 errata-xmlrpc 2016-08-22 12:23:45 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-2016-1645.html