Bug 1247525 - rhnservergroup table thrown error when run insert/update sql.
rhnservergroup table thrown error when run insert/update sql.
Status: CLOSED NOTABUG
Product: Spacewalk
Classification: Community
Component: Server (Show other bugs)
2.2
x86_64 Linux
unspecified Severity urgent
: ---
: ---
Assigned To: Jan Dobes
Jan Hutař
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-07-28 04:54 EDT by Muhammad Aizuddin
Modified: 2016-11-10 15:23 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-11-10 15:23:05 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Muhammad Aizuddin 2015-07-28 04:54:39 EDT
Description of problem:
When executing below statement,

stmt = "insert into rhnservergroup (id, name, description, org_id) values (rhn_server_group_id_seq.nextval, '%s', '%s', 2)" % (name, description)

we have ORA error saying that,
cx_Oracle.DatabaseError: ORA-20297: Call get_log_id need to follow set_log_auth.
ORA-06512: at "SPACEWALK.LOGGING", line 29
ORA-06512: at "SPACEWALK.RHNSERVERGROUP_LOG_TRIG", line 5
ORA-04088: error during execution of trigger 'SPACEWALK.RHNSERVERGROUP_LOG_TRIG'

As workaround we had to disabled RHNSERVERGROUP_LOG_TRIG trigger and the statement will work without any errors.

Version-Release number of selected component (if applicable):
oracle-xe-11.2.0-1.0.x86_64
spacewalk-oracle-2.2.2-1.el6.noarch


How reproducible:
Execute insert/update sql statement into rhnservergroup table.

Steps to Reproduce:
1.
2.
3.

Actual results:
Insert/Update should not give any errors.

Expected results:


Additional info:
Comment 1 Avi Miller 2015-08-27 02:14:54 EDT
This is not a bug. You need to call clear_log_id() and set_log_auth(:user_id) prior to running the insert. Otherwise, the trigger won't fire correctly. This is handled automatically by Spacewalk's Hibernate Factory and the Logging mechanisms associated with creating new objects via Java (and the API).

Pseudo-code would look something like this (in PL/SQL):

begin
    logging.clear_log_id();
    logging.set_log_auth(1);
    insert into rhnservergroup (id, name, description, org_id) values (rhn_server_group_id_seq.nextval, :name, :description, :org_id);
end;
/

This assumes you're inserting with the user_id of 1, which is the initial super-admin account.
Comment 2 Fedora Update System 2015-10-02 14:08:30 EDT
subversion-1.8.14-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-be2c11d456
Comment 3 Muhammad Aizuddin 2015-10-04 03:13:48 EDT
Hi Avi,

Thank you for looking at this. I concur the same after reading schema docs. Hence this is enhancement to the database-application structure.

Regards
Comment 4 Fedora Update System 2015-12-16 12:21:27 EST
subversion-1.8.15-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-6efa349a85
Comment 5 Fedora Update System 2015-12-17 05:28:19 EST
subversion-1.8.15-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update subversion'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-6efa349a85
Comment 6 Jan Hutař 2016-11-10 15:23:05 EST
Great, looks like no code change was required here.

I have tested on both SWnightly@OracleXE10@RHEL6 and SWnightly@PostgreSQL@RHEL7 (spacewalk-schema-2.6.14-1.el?.noarch) by creating new organization what creates new records in the table and yay, new records were created:

@Oracle before new organization creation:


# echo "SELECT * FROM rhnservergroup;" | spacewalk-sql --select-mode-direct -

	ID NAME 							    DESCRIPTION 																			     CURRENT_MEMBERS GROUP_TYPE     ORG_ID CREATED								       MODIFIED
---------- ---------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------- ---------- ---------- --------------------------------------------------------------------------- ---------------------------------------------------------------------------
	 1 Spacewalk Management Entitled Servers			    Spacewalk Management Entitled Servers																   0	      1 	 1 10-NOV-16 10.37.05.418097 AM 					       10-NOV-16 10.37.05.418369 AM
	 2 Virtualization Host Entitled Servers 			    Virtualization Host Entitled Servers																   0	      2 	 1 10-NOV-16 10.37.05.430974 AM 					       10-NOV-16 10.37.05.431062 AM


@Oracle after new organization created:


# echo "SELECT * FROM rhnservergroup;" | spacewalk-sql --select-mode-direct -

	ID NAME 							    DESCRIPTION 																			     CURRENT_MEMBERS GROUP_TYPE     ORG_ID CREATED								       MODIFIED
---------- ---------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------- ---------- ---------- --------------------------------------------------------------------------- ---------------------------------------------------------------------------
	 3 Spacewalk Management Entitled Servers			    Spacewalk Management Entitled Servers																   0	      1 	 2 10-NOV-16 09.16.42.534602 PM 					       10-NOV-16 09.16.42.534674 PM
	 4 Virtualization Host Entitled Servers 			    Virtualization Host Entitled Servers																   0	      2 	 2 10-NOV-16 09.16.42.562595 PM 					       10-NOV-16 09.16.42.562668 PM
	 1 Spacewalk Management Entitled Servers			    Spacewalk Management Entitled Servers																   0	      1 	 1 10-NOV-16 10.37.05.418097 AM 					       10-NOV-16 10.37.05.418369 AM
	 2 Virtualization Host Entitled Servers 			    Virtualization Host Entitled Servers																   0	      2 	 1 10-NOV-16 10.37.05.430974 AM 					       10-NOV-16 10.37.05.431062 AM


@PostgreSQL before:


# echo "SELECT * FROM rhnservergroup;" | spacewalk-sql --select-mode-direct -
 id |                 name                  |              description              | current_members | group_type | org_id |            created            |           modified            
----+---------------------------------------+---------------------------------------+-----------------+------------+--------+-------------------------------+-------------------------------
  1 | Spacewalk Management Entitled Servers | Spacewalk Management Entitled Servers |               0 |          1 |      1 | 2016-11-10 10:24:26.639337+01 | 2016-11-10 10:24:26.639337+01
  2 | Virtualization Host Entitled Servers  | Virtualization Host Entitled Servers  |               0 |          2 |      1 | 2016-11-10 10:24:26.639337+01 | 2016-11-10 10:24:26.639337+01
(2 rows)


@PostgreSQL after:


# echo "SELECT * FROM rhnservergroup;" | spacewalk-sql --select-mode-direct -
 id |                 name                  |              description              | current_members | group_type | org_id |            created            |           modified            
----+---------------------------------------+---------------------------------------+-----------------+------------+--------+-------------------------------+-------------------------------
  1 | Spacewalk Management Entitled Servers | Spacewalk Management Entitled Servers |               0 |          1 |      1 | 2016-11-10 10:24:26.639337+01 | 2016-11-10 10:24:26.639337+01
  2 | Virtualization Host Entitled Servers  | Virtualization Host Entitled Servers  |               0 |          2 |      1 | 2016-11-10 10:24:26.639337+01 | 2016-11-10 10:24:26.639337+01
  3 | Spacewalk Management Entitled Servers | Spacewalk Management Entitled Servers |               0 |          1 |      2 | 2016-11-10 21:17:20.981545+01 | 2016-11-10 21:17:20.981545+01
  4 | Virtualization Host Entitled Servers  | Virtualization Host Entitled Servers  |               0 |          2 |      2 | 2016-11-10 21:17:20.981545+01 | 2016-11-10 21:17:20.981545+01
(4 rows)

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