Bug 1758292

Summary: Check and reset sessions_id_seq in postgres
Product: Red Hat Satellite Reporter: sthirugn <sthirugn>
Component: Satellite MaintainAssignee: Anurag Patel <apatel>
Status: CLOSED DUPLICATE QA Contact: Nikhil Kathole <nkathole>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5.0CC: apatel, inecas, kgaikwad, mbacovsk
Target Milestone: UnspecifiedKeywords: FieldEngineering, PrioBumpField, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-10-07 11:05:33 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:

Description sthirugn@redhat.com 2019-10-03 18:54:24 UTC
Description of problem:
A Satellite running for many many years may run into integer out of range. This is rare but possible.

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

How reproducible:
Difficult to reproduce but happens very rarely at customer environments

Steps to Reproduce:
1. It is difficult to reproduce as a normal user, but can be reproduced easily with updating the table.
2. sudo su - postgres
   psql foreman
      ALTER SEQUENCE sessions_id_seq RESTART WITH 9223372036854775805;
3. Now, hit some api calls or hammer or UI.

Actual results:
curl -X GET -k -u admin:changeme https://satellite.example.com/api/v2/hosts
{
  "error": {"message":"PG::NumericValueOutOfRange: ERROR:  integer out of range\n: INSERT INTO \"sessions\" (\"session_id\", \"data\", \"created_at\", \"updated_at\") VALUES ($1, $2, $3, $4) RETURNING \"id\""}
}

At this point, you can't login to UI as well.

production.log would show:
==> /var/log/foreman/production.log <==
2019-10-03T18:52:42 [I|app|] Started GET "/api/v2/hosts" for 192.168.121.1 at 2019-10-03 18:52:42 +0000
2019-10-03T18:52:42 [I|app|f447d679] Processing by Api::V2::HostsController#index as JSON
2019-10-03T18:52:42 [I|app|f447d679]   Parameters: {"apiv"=>"v2"}
2019-10-03T18:52:42 [I|app|f447d679] Authorized user admin(Admin User)
2019-10-03T18:52:42 [I|app|f447d679] Current user set to admin (admin)
2019-10-03T18:52:42 [W|app|f447d679] Action failed
ActiveRecord::StatementInvalid: PG::ObjectNotInPrerequisiteState: ERROR:  nextval: reached maximum value of sequence "sessions_id_seq" (9223372036854775807)
: INSERT INTO "sessions" ("session_id", "data", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"


Expected results:
The sessions_id_seq should be reset once in a while to avoid this error.

Additional info:
This kcs article explains how to clear the sessions and reset the sequence: https://access.redhat.com/solutions/3660801

Comment 4 Kavita 2019-10-07 11:05:33 UTC

*** This bug has been marked as a duplicate of bug 1641223 ***