There is a race condition:
You are entirely right, of course. I asked about this on #postgresql on IRC (freenode), and they didn't give me a better answer than your first try. Wasting IDs is rather ugly -- though I'm not sure this would be a concrete problem. Using ignore-errors is probably bad. Each postmodern exception has a database-error-code accessor, which can be used to identify a specific type of errors, and let all others through.
Hope that helps. If you come up with a better way, let me know.
Cheers, Marijn