ERROR: nextval: reached maximum value of sequence "logs_id_seq" in Red Hat Satellite 6

Solution Verified - Updated

Environment

  • Red Hat Satellite
    • 6.15
    • 6.16
    • 6.17

Issue

  • The Ansible callback that is uploading data to Satellite is getting error 500.

  • Some services using Satellite API fail with 500 errors, most of them starting with the following text:

        2025-09-25T15:49:24 [W|app|afca0a76] Action failed
    2025-09-25T15:49:24 [I|app|afca0a76] Backtrace for 'Action failed' error (ActiveRecord::StatementInvalid): PG::SequenceGeneratorLimitExceeded: ERROR:  nextval: reached maximum value of sequence "logs_id_seq" (2147483647)
    

Resolution

  • This issue has been reported to the Red Hat Satellite Engineering team via This content is not included.SAT-38813 bug and is being actively investigated.

  • To fix the issue manually on the affected Red Hat Satellite server, proceed with the following steps:

    1. Ensure that a backup or VM snapshot exists for the affected Red Hat Satellite server, before proceeding further.

    2. Clear any paused tasks that might be present.

      # foreman-rake foreman_tasks:cleanup TASK_SEARCH='label ~ *' STATES='paused' VERBOSE=true
      
    3. Check the max_value and last_value of logs_id_seq sequence in foreman database. They are expected to be the same at this point.

      # echo "select * from pg_sequences where sequencename='logs_id_seq';" | su - postgres -c "psql -x foreman"
      
    4. Fix the issue:

      # echo "ALTER SEQUENCE logs_id_seq AS bigint;" | su - postgres -c "psql foreman"
      
    5. Verify that max_value is now much higher than last_value for logs_id_seq sequence and its data_type is set as bigint

      # echo "select * from pg_sequences where sequencename='logs_id_seq';" | su - postgres -c "psql -x foreman"
      
    6. Restart the services.

      # satellite-maintain service restart
      # sleep 20 & hammer ping
      
  • Reach out to Red Hat Technical Support in case of any further questions or concerns.

For more KB articles/solutions related to Red Hat Satellite 6.x PostgreSQL-related Issues, please refer to the Consolidated Troubleshooting Article for Red Hat Satellite 6.x PostgreSQL-related Issues

Root Cause

  • As it can be observed in the Diagnostic Steps section,
    • The id column of public.logs table is of integer data type and depends on logs_id_seq.
    • The logs_id_seq itself also has the data type set to integer due to which the value of the max_value field is limited to 2147483647 and the last_value field has reached that specific limit.

Diagnostic Steps

  • The following traceback recurs a lot in /var/log/foreman/production.log:

        2025-09-25T15:49:24 [W|app|afca0a76] Action failed
    2025-09-25T15:49:24 [I|app|afca0a76] Backtrace for 'Action failed' error (ActiveRecord::StatementInvalid): PG::SequenceGeneratorLimitExceeded: ERROR:  nextval: reached maximum value of sequence "logs_id_seq" (2147483647)
    
  • Inspecting the sequence and table in concern, the following can be found in the foreman database.

        # echo "select * from pg_sequences where sequencename='logs_id_seq';" | su - postgres -c "psql -x foreman"
    -[ RECORD 1 ]-+------------
    schemaname    | public
    sequencename  | logs_id_seq
    sequenceowner | foreman
    data_type     | integer
    start_value   | 1
    min_value     | 1
    max_value     | 2147483647   ------------------> Not large enough value
    increment_by  | 1
    cycle         | f
    cache_size    | 1
    last_value    | 2147483647   ------------------> same as max_value which means it had reached its limit
    
    • It's not expected data_type for the id field or the sequence to be integer as the table can hold a lot of records and should have a large enough max_value (and that can be achieved from bigint data type).
SBR
Product(s)
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.