I am getting an error trying to save a new content or update it that contains paragraphs.
I am using Drupal core 8.4.0, Paragraphs 8.x-1.2 and psql (PostgreSQL) 9.6.5 in Ubuntu 17.04, all the last versions including last versions of all the modules used in Drupal.
I have tried also with the dev version of paragraphs without result.
The error that I am getting is:
Drupal\Core\Entity\EntityStorageException: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "paragraphs_item_revision____pkey" DETAIL: Key (revision_id)=(37) already exists.: INSERT INTO paragraphs_item_revision (id, langcode, revision_uid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (Zeile 805 in core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Any idea how to solve this problem? Or what I could try?
Comments
Comment #2
dimr commentedComment #3
johnchqueHmmm this is pretty strange, do you have a similar problem when using other referenced entities? Not really sure what could be the cause this to affect to Paragraphs only.
Comment #4
dimr commentedI have tried in another content type with an entity reference field to a content, and it works...
In the meanwhile, I have updated to 8.4.2 but I still have the same error.
Any idea that I could try?
Comment #5
johnchqueIt seems pretty strange, it is like the id has not been incremented when added a new Paragraph. Did you have some error when trying to save a node with Paragraphs that showed you a WSOD or something like that?
Comment #6
dimr commentedHi,
I don't remember to see something like that. I have tried also with dev version but it is not working either.
Looking for some information I have found this that maybe can be the problem, but I am afraid that even with that information, I have tried to debug the error, but I don't see anywhere in the code where I could check that.
https://dba.stackexchange.com/a/130121
Postgres handles auto incrementing a little differently than MySQL does. In Postgres, when you create the serial field, you are also creating a sequence field that is keeping track of the id to use. This sequence field is going to start out with a value of 1.
When you insert a new record into the table, if you don't specify the id field, it will use the value of the sequence, and then increment the sequence. However, if you do specify the id field, then the sequence is not used, and it is not updated, either.
Comment #7
dimr commentedI have tried with a new Drupal instance 8.4.2 and the same paragraph module version, and I cannot reproduce the error.
I have created a new content type with a new paragraph type in the problematic project and the problem still appear.
Anyone has any idea that I could try, please?
Comment #8
dimr commentedComment #9
dimr commentedFinally, yongt9412 where right and it was a problem directly from the database, the last_value was outdated, and we resolved it updating "manually the value"
Before was:
but the real last value was 141, then we change it to
Thanks for the support!