The client could catch these errors and retry, but then it could also do that with serializable transactions on serialization failures (SQLSTATE 40001), and you'd get the guarantee of consecutive numbering without creating all these sequences, not to mention the protection against other potential concurrency anomalies. See https://www.postgresql.org/docs/current/transaction-iso.html
Best regards, -- Daniel Vérité PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite
Indeed. We have a "creation state" in the application. During that moment the pair(group,element) and the sequence will be created.
After the creation process is done, the entry is in "production state" and the sequence will be used only then.