Bug 502476 - rhn_sat_node should have uniq constraint on column server_id
Summary: rhn_sat_node should have uniq constraint on column server_id
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Server
Version: 530
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Preethi Thomas
URL:
Whiteboard:
Depends On:
Blocks: 463877 499399
TreeView+ depends on / blocked
 
Reported: 2009-05-25 12:29 UTC by Miroslav Suchý
Modified: 2009-09-10 18:49 UTC (History)
2 users (show)

Fixed In Version: sat530
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-09-10 18:49:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Miroslav Suchý 2009-05-25 12:29:00 UTC
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,
            );
  $sc->create_new();

  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):
sat530

How reproducible:
always

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 12:48:49 UTC
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 12:43:24 UTC
verified
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 12:16:19 UTC
Verified in stage: script above generates ORA-02291

SQL> select index_name,
            table_name,
            uniqueness
     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

RELEASE_PENDING

Comment 4 Brandon Perkins 2009-09-10 18:49:47 UTC
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.

http://rhn.redhat.com/errata/RHEA-2009-1434.html


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