I had an interesting circumstance happen with Postgres (PostgreSQL) and I want to remember how I fixed the problem.
Somehow I had four entries in a database table, but the key for that table thought that there were only two entries. I don't yet know how this happened, but at the time I didn't care, I just needed to get past the problem. The details of the problem, and the fix, follow.
In my case the table name was carrier, and this table and the key were created like this: