Bug #26009
closedClear session count to be able to login again
Description
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'
===
Steps to Reproduce:
1. It is unclear how this actually happens in production, reproducer is to 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)
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:
Fix is to restart the sequence with 1 to bring your Foreman back online.
foreman=# alter sequence sessions_id_seq restart with 1;
ALTER SEQUENCE