A successful data load that explicitly inserts rows with fixed IDs leaves the associated sequence out of sync, causing subsequent application inserts to fail with duplicate key errors. This occurs because explicit ID values do not automatically update the sequence's next value. The issue is not data corruption but a simple synchronization gap between the table's max ID and the sequence generator.
- Explicit ID inserts bypass sequence updates, leaving them out of sync with data.
- Subsequent auto-generated inserts will collide with existing high-watermark IDs.
- Verify sequence values against table max IDs after bulk loads or restores.
- Use setval() to manually align sequences with existing data ranges.