Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1641223 - Can't create a new session in foreman: integer out of range
Summary: Can't create a new session in foreman: integer out of range
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Users & Roles
Version: 6.4
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: 6.7.0
Assignee: Suraj Patil
QA Contact: Radovan Drazny
URL:
Whiteboard:
: 1758292 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-10-20 03:56 UTC by Alexey Masolov
Modified: 2023-09-07 19:28 UTC (History)
16 users (show)

Fixed In Version: foreman-1.24.1.5-1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-14 13:23:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 26009 0 Normal Resolved Clear session count to be able to login again 2020-08-18 20:29:10 UTC
Foreman Issue Tracker 29027 0 Normal Closed Session id out of range error 2020-08-18 20:29:10 UTC
Github theforeman foreman pull 7441 0 None closed Fixes #29027 - session_id out of range error 2020-08-18 20:29:12 UTC
Github theforeman foreman pull 7448 0 None closed Refs #29027 - session out of range adhere pg versions 2020-08-18 20:29:11 UTC
Github theforeman foreman pull 7457 0 None closed Refs #29027 - replace server_version with server_version_num 2020-08-18 20:29:12 UTC
Red Hat Knowledge Base (Solution) 3660801 0 None None None 2018-11-06 06:30:29 UTC
Red Hat Product Errata RHSA-2020:1454 0 None None None 2020-04-14 13:23:40 UTC

Description Alexey Masolov 2018-10-20 03:56:02 UTC
Description of problem:
Can't open a new foreman session. WebUI gives "We're sorry, but something went wrong.". API calls return Error 500. 

=== production.log ===
2018-10-19 11:46:36 39364d1c [app] [F]
 | ActiveRecord::StatementInvalid (PG::Error: ERROR:  integer out of range
 | : INSERT INTO "sessions" ("created_at", "data", "session_id", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"):
 |   lib/middleware/tagged_logging.rb:18:in `call'
===

=== postgresql.log ===
2018-10-20 14:40:18 AEDT STATEMENT:  INSERT INTO "sessions" ("session_id", "data", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"
2018-10-20 14:40:18 AEDT ERROR:  integer out of range
2018-10-20 14:40:18 AEDT STATEMENT:  INSERT INTO "sessions" ("session_id", "data", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "id"
===

Version-Release number of selected component (if applicable):
Satellite 6.2, 6.3, 6.4

How reproducible:
100%

Steps to Reproduce:
1. Clean your sessions to avoid further mess by running 'foreman-rake db:sessions:clear'
2. Modify your last value in foreman.sessions_id_seq to something bigger than integer. So the next value for ID in foreman.sessions will be bigger than integer. Like:

foreman=# alter sequence sessions_id_seq restart with 2151782968;
ALTER SEQUENCE
foreman=# select * from sessions_id_seq;
  sequence_name  | last_value | start_value | increment_by |      max_value      | min_value | cache_value | log_cnt | is_cycled | is_called
-----------------+------------+-------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
 sessions_id_seq | 2151782969 |           1 |            1 | 9223372036854775807 |         1 |           1 |      31 | f         | t
(1 row)
foreman=# \d+ sessions;
                                                         Table "public.sessions"
   Column   |            Type             |                       Modifiers                       | Storage  | Stats target | Description
------------+-----------------------------+-------------------------------------------------------+----------+--------------+-------------
 id         | integer                     | not null default nextval('sessions_id_seq'::regclass) | plain    |              |
 session_id | character varying(255)      | not null                                              | extended |              |
 data       | text                        |                                                       | extended |              |
 created_at | timestamp without time zone |                                                       | plain    |              |
 updated_at | timestamp without time zone |                                                       | plain    |              |
Indexes:
    "sessions_pkey" PRIMARY KEY, btree (id)
    "index_sessions_on_session_id" btree (session_id)
    "index_sessions_on_updated_at" btree (updated_at)

3. Done. 


Actual results:
"We're sorry, but something went wrong." in the webui. Not able to register new servers, etc. 

Expected results:
Functionality as usual.

Additional info:
Restart the sequence with 1 to bring your Satellite back online. 

foreman=# alter sequence sessions_id_seq restart with 1;
ALTER SEQUENCE

Comment 5 Ondřej Pražák 2019-02-07 07:22:38 UTC
Created redmine issue http://projects.theforeman.org/issues/26009 from this bug

Comment 9 Kavita 2019-10-07 11:05:33 UTC
*** Bug 1758292 has been marked as a duplicate of this bug. ***

Comment 15 Ondřej Ezr 2020-02-18 15:01:47 UTC
Linking an issue, that contains an easyfix.

Comment 19 Radovan Drazny 2020-03-10 09:50:31 UTC
Verified on Sat 6.7 Snap 15.

Logged out from the WebUI, run 'foreman-rake db:sessions:clear'

$ sudo -u foreman psql

foreman=> select * from sessions_id_seq;
  sequence_name  | last_value | start_value | increment_by |      max_value      | min_value | cache_value | log_cnt | is_cycled | is_called 
-----------------+------------+-------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
 sessions_id_seq |        269 |           1 |            1 | 9223372036854775807 |         1 |           1 |      29 | t         | t
(1 row)

The max value has been set to the PG bigint value.

foreman=> alter sequence sessions_id_seq restart with 9223372036854775807;                                          
ALTER SEQUENCE

foreman=> select * from sessions_id_seq;
  sequence_name  |     last_value      | start_value | increment_by |      max_value      | min_value | cache_value | log_cnt | is_cycled | is_called 
-----------------+---------------------+-------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
 sessions_id_seq | 9223372036854775807 |           1 |            1 | 9223372036854775807 |         1 |           1 |       0 | t         | f
(1 row)


Logged back into the WebUI, did some clicking around.


foreman=> select * from sessions_id_seq;
  sequence_name  | last_value | start_value | increment_by |      max_value      | min_value | cache_value | log_cnt | is_cycled | is_called 
-----------------+------------+-------------+--------------+---------------------+-----------+-------------+---------+-----------+-----------
 sessions_id_seq |          5 |           1 |            1 | 9223372036854775807 |         1 |           1 |      29 | t         | t
(1 row)


The value correctly rolled over the bigint limit, and started the sequence from 1 again.

Comment 22 errata-xmlrpc 2020-04-14 13:23:25 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


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