Get sql-error when trying to create a new attribute

When I try to create a new attribute it fails.
Webpage shows:

Error 200: An exception occurred while executing a query: SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction has been aborted, all commands are ignored until the end of the transaction

In sql-servers logg:

2025-10-21 15:31:55.082 CEST [394867] DETAILS: The key (id)=(313) already exists.
2025-10-21 15:31:55.082 CEST [394867] STATEMENT: INSERT INTO user_followed_record (entity_id, entity_type, user_id) VALUES($1, $2, $3)
2025-10-21 15:31:55.083 CEST [394867] ERROR: current transaction has been aborted, all commands are ignored until the end of the transaction
2025-10-21 15:31:55.083 CEST [394867] STATEMENT: INSERT INTO "note" ("id", "deleted", "data", "type", "created_at", "modified_at", "parent_id", "parent_type", "created_by_id", "modified_by_id") VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)

I have not done mutch with the server except updating the os.
The last time I added an attribute was almost a year ago.
And I have not been able to update pim for a very long time now, so i“m still running v1.11.10
What can I do to troubleshoot more?
In the table ā€œuser_followed_recordā€ the highest ID is 446, and every time I try the id is enumerated, now at 314, is the id-counter broken?

I found out that late 2024 I migrated from mysql to postgresql.
It may be that no new attribute has been made in postgresql.
I manage to create my attribute I need now, by making an import-job that imports the attribute, and ran it over and over again until it found a free id.
so about 80 imports later, I found that id 396 was free :slight_smile:
I still have to run it 40 times more until id is bigger than largest id i table.

Hi Lennart,
i think during the migration to postgres, sequence of that table has not been migrated.
To fix that, please execute this query :
SELECT setval(ā€˜user_followed_record_id_seq’, (SELECT MAX(id) FROM user_followed_record) + 1);
Thanks.

1 Like

Thank you so mutch, worked like a charm.

1 Like