If you did it inside a transaction, then checking in psql doesn't really tell you if the key already exists in the db. When you get the duplicate key insertion, the whole transaction is rolled back, so you wouldn't be able to tell if a duplicate was inserted. You need to look at all thirty inserts and make sure that you don't have a duplicate in the transaction. A good way to check is to run aolserver inside shell mode of emacs and search backwards for the duplicate insert.