PG::SequenceGeneratorLimitExceeded: ERROR: nextval: reached maximum value of sequence "logs_id_seq" (2147483647)

I thought I had covered most edge cases for our Foreman infrastructure, although one I didnt consider was the number of log files that 70,000 hosts will create. After a year in business, we’ve finally hit that. I am seeing this in our logs:

2025-11-25T17:52:33 [E|app|e6e863ae] Error importing log messages for report ID: 26772210: PG::SequenceGeneratorLimitExceeded: ERROR:  nextval: reached maximum value of sequence "logs_id_seq" (2147483647)
e6e863ae |
2025-11-25T17:52:33 [E|app|e6e863ae] Error processing normal report for host: qaregauto.ssnc.global: PG::SequenceGeneratorLimitExceeded: ERROR:  nextval: reached maximum value of sequence "logs_id_seq" (2147483647)
e6e863ae |
2025-11-25T17:52:33 [E|app|e6e863ae] Error importing report for qaregauto.ssnc.global: PG::SequenceGeneratorLimitExceeded: ERROR:  nextval: reached maximum value of sequence "logs_id_seq" (2147483647)
e6e863ae |
2025-11-25T17:52:33 [E|app|e6e863ae] Failed to import reports: PG::SequenceGeneratorLimitExceeded: ERROR:  nextval: reached maximum value of sequence "logs_id_seq" (2147483647)
e6e863ae |
2025-11-25T17:52:33 [E|bac|e6e863ae] PG::SequenceGeneratorLimitExceeded: ERROR:  nextval: reached maximum value of sequence "logs_id_seq" (2147483647)
e6e863ae |  (ActiveRecord::StatementInvalid)

We seem to have hit the max number of logs allowed in the table. I’ve tried to run:
foreman-rake reports:expire days=10 But that doesnt actually seem to delete the rows of logs associated with reports?

Can I just set logs_id_seq to bigint and call it a day?

The answer is yes. Flipping it to bigint, then restarting the services, fixed it.

ALTER SEQUENCE logs_id_seq
  AS bigint;

SELECT setval(
  'logs_id_seq',
  COALESCE((SELECT MAX(id) FROM logs), 1),
  true
);

70,000 minions all running 1-5 times a day = lots of report lines. :slight_smile:

Although Im still questioning if using the rake command removes them from the DB, because we ran it down to removing reports from just the last day and the max int never went down in the DB.

2 Likes