Bug 1793701

Summary: Content View publishing fails after katello_repository_rpms "id" column hits max integer size
Product: Red Hat Satellite Reporter: Dylan Gross <dgross>
Component: Content ManagementAssignee: Justin Sherrill <jsherril>
Status: CLOSED ERRATA QA Contact: Lai <ltran>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 6.6.0CC: jsherril, zhunting
Target Milestone: 6.7.0Keywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: tfm-rubygem-katello-3.14.0.10-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-14 13:28:34 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:
Attachments:
Description Flags
database migration file none

Description Dylan Gross 2020-01-21 21:17:08 UTC
Description of problem:

  Content View publishing fails after katello_repository_rpms "id" column hits max integer size


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

  Red Hat Satellite 6.6  (but I believe all supported versions would be susceptible)

How reproducible:
Steps to Reproduce:
1.   Publish, publish, publish new content until the number of INSERTS (which increment "id" on every new row finally hits Integer max size (or close enough that the next publish would increment it above the Max)


Actual results:

   

Expected results:

   Publishes succeed.

Additional info:

Error in dynflow task:
----------------------------------------------------------------
PG::NumericValueOutOfRange: ERROR:  integer out of range

: INSERT INTO katello_repository_rpms (rpm_id, repository_id, created_at, updated_at) VALUES 
   (494939, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (249613, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (249614, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (393610, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (287208, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (249616, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (397182, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (353289, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (228061, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (383234, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (369162, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (488882, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (365164, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (494940, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (393611, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (430253, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (228062, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (489006, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (228871, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (365425, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (256320, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (420443, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (365426, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (398249, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (431032, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14'), 
   (487077, 751553, '2020-01-21 14:03:14', '2020-01-21 14:03:14')
----------------------------------------------

As neither of the two integers being inserted above (rpm_id, or repository_id) appear to be anywhere close to the integer max size, they're unlikely to be the culprits. 

--------------------------------------------------
foreman=# \d katello_repository_rpms
                                       Table "public.katello_repository_rpms"
    Column     |            Type             |                              Modifiers                               
---------------+-----------------------------+----------------------------------------------------------------------
 id            | integer                     | not null default nextval('katello_repository_rpms_id_seq'::regclass)
 rpm_id        | integer                     | not null
 repository_id | integer                     | 
 created_at    | timestamp without time zone | 
 updated_at    | timestamp without time zone | 
Indexes:
    "katello_repository_rpms_pkey" PRIMARY KEY, btree (id)
    "index_katello_repository_rpms_on_rpm_id_and_repository_id" UNIQUE, btree (rpm_id, repository_id)
    "index_katello_repository_rpms_on_repository_id" btree (repository_id)
Foreign-key constraints:
    "katello_repository_rpms_repository_id_fk" FOREIGN KEY (repository_id) REFERENCES katello_repositories(id)
    "katello_repository_rpms_rpm_id_fk" FOREIGN KEY (rpm_id) REFERENCES katello_rpms(id)

foreman=# 
--------------------------------------------------------------

 Rather, it is the "id" that is incremented on every new row that is hitting the max, and the following shows that it's currently super close.

----------------------------------------------------


foreman=# select MAX(id) from katello_repository_rpms;
    max     
------------
 2147478931
(1 row)

Comment 4 Justin Sherrill 2020-01-21 22:28:23 UTC
Created redmine issue https://projects.theforeman.org/issues/28831 from this bug

Comment 5 Justin Sherrill 2020-01-21 22:30:59 UTC
Created attachment 1654409 [details]
database migration file

Comment 6 Justin Sherrill 2020-01-21 22:32:38 UTC
To apply patch:

Drop the attached file into the /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.12.0.29/db/migrate/ directory, so that it exists as: /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.12.0.29/db/migrate/20200121213430_katello_repository_rpms_id_big_int.rb

Run:

foreman-rake db:migrate
systemctl restart httpd dynflowd

Comment 7 Bryan Kearney 2020-01-21 23:03:00 UTC
Upstream bug assigned to jsherril

Comment 8 Bryan Kearney 2020-01-21 23:03:01 UTC
Upstream bug assigned to jsherril

Comment 9 Bryan Kearney 2020-01-22 15:04:11 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/28831 has been resolved.

Comment 12 Lai 2020-02-10 16:31:16 UTC
Steps to retest:

1. Check postgres database table for BIGINT for ID column.

Expected result: id -> bigint

Actual result:
foreman=# \d katello_repository_rpms
                                       Table "public.katello_repository_rpms"
    Column     |            Type             |                              Modifiers                    
           
---------------+-----------------------------+-----------------------------------------------------------
-----------
 id            | bigint                      | not null default nextval('katello_repository_rpms_id_seq':
:regclass)
 rpm_id        | integer                     | not null
 repository_id | integer                     | 
 created_at    | timestamp without time zone | 
 updated_at    | timestamp without time zone | 
Indexes:


Second way of verifying:
1. Create a custom repo
2. Sync repo
3. Create cv and add custom repo from step 1
4. Publish cv
5. Log into postgres database
6. Update id to something above the 2,147,483,647 max. i.e. foreman=# update katello_repository_rpms set id=3147478933 where id in (Select max(id) from katello_repository_rpms);

Expected result:
UPDATE 1

Actual result:
UPDATE 1

Note: For the second way of verifying, if you update above the 2147483647 max, it'll give "ERROR: integer out of range"  IF THE ID DATATYPE was still in "integer".  Switching to "bigint" has a higher max value so it should not give the error message.  In this case, it did not give the error message.

Tested on 6.7.0_011.  Marking issue as verified.

Comment 15 errata-xmlrpc 2020-04-14 13:28:34 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://access.redhat.com/errata/RHSA-2020:1454