SQLSTATE 2200HSeverity mediumLab verified

Incident brief

Sequence reached its maximum value

nextval() fails once a non-cycling sequence hits its MAXVALUE; a sequence capped at 2 raised the limit error on the third call.

Reproduced on PostgreSQL 18.4Verified 2026-07-24 (isolated lab, PostgreSQL 18.4)Reviewed by Verified against PostgreSQL 18.4 in an isolated lab environment

In 10 seconds

What
Sequence reached its maximum value
What triggers it
Create or reach a sequence with a low MAXVALUE and no CYCLE.
The fix
Raise the sequence's MAXVALUE (or move the column and sequence to bigint) so it has room to grow.
Proof
Reproduced on PostgreSQL 18.4 → The reproduction exhausts a MAXVALUE-2 sequence: nextval returns 1 then 2, and the third call raises SQLSTATE 2200H.

The fix

What to do right now

The immediate, application-level response to this error.

  • Raise the sequence's MAXVALUE (or move the column and sequence to bigint) so it has room to grow.
  • Add CYCLE only if wrapping is acceptable and duplicate keys are impossible.
Fix — SQL
-- Raise the ceiling so the sequence can advance again.
ALTER SEQUENCE order_seq MAXVALUE 100;
SELECT nextval('order_seq');

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 18.4
Last verified
2026-07-24 (isolated lab, PostgreSQL 18.4)
Reviewed by
Verified against PostgreSQL 18.4 in an isolated lab environment
Audit status
reviewed