Bug 502476 - rhn_sat_node should have uniq constraint on column server_id
rhn_sat_node should have uniq constraint on column server_id
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Server (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Miroslav Suchý
Preethi Thomas
Depends On:
Blocks: 463877 499399
  Show dependency treegraph
Reported: 2009-05-25 08:29 EDT by Miroslav Suchý
Modified: 2009-09-10 14:49 EDT (History)
2 users (show)

See Also:
Fixed In Version: sat530
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-09-10 14:49:47 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Miroslav Suchý 2009-05-25 08:29:00 EDT
Description of problem:
rhn_sat_node should have uniq constraint on column server_id
Try to run this script twice:

use  RHN::Utils;
use RHN::SatCluster;

  my $hostname = "vmware113.englab.brq.redhat.com";
  my $vip = RHN::Utils::find_ip_address($hostname);

  my $sc = new RHN::SatCluster(customer_id => 1,
             description => "chod inam",
             last_update_user => 'installer',
             server_id => '1000010492',
             vip => $vip,

  my $key = RHN::SatCluster->fetch_key($sc->recid);
  print "$key\n";

note: substitute hostename and server id for some machine you have registred to your satellite.
If you run it twice you will get two scouts for the same machine. Which is what we do not want

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

How reproducible:

Steps to Reproduce:
1. run twice given script
Actual results:
two scouts in webui

Expected results:
second run of script fail and only one scout in webui.

Additional info:
Comment 1 Miroslav Suchý 2009-05-25 08:48:49 EDT
Commited as e63a160a151d4ed0cd3312ecde90f8181fb81fbb

Now insert of second scout on the same machine should give error. The given script shoud say:
# perl /tmp/a.pl
RHN::Exception: DBD::Oracle::st execute failed: ORA-00001: unique constraint (RHNSAT.RHN_SAT_NODE_SID_IDX) violated (DBD ERROR: OCIStmtExecute) [for Statement "
    INSERT INTO rhn_sat_node (
Comment 2 Preethi Thomas 2009-06-02 08:43:24 EDT
ISO: Satellite-5.3.0-RHEL5-re20090529.0-i386-embedded-oracle.iso

msuchy [root@rlx-3-24 ~]# perl -wc script.sh
msuchy script.sh syntax OK
msuchy [root@rlx-3-24 ~]# perl script.sh
msuchy 4070f1ca306b
msuchy [root@rlx-3-24 ~]# perl script.sh
msuchy RHN::Exception:
Comment 3 Milan Zázrivec 2009-08-24 08:16:19 EDT
Verified in stage: script above generates ORA-02291

SQL> select index_name,
     from user_indexes
     where index_name = upper('rhn_sat_node_sid_idx');

INDEX_NAME                     TABLE_NAME                     UNIQUENES
------------------------------ ------------------------------ ---------
RHN_SAT_NODE_SID_IDX           RHN_SAT_NODE                   UNIQUE

Comment 4 Brandon Perkins 2009-09-10 14:49:47 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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