Problem with duplicate key value violating unique constraint "publication_galleys_pkey"

Description of issue or problem I’m having:

While trying to add a new galley, we are seeing this in apache’s error.log:

[Mon Apr 04 15:26:59.472243 2022] [php7:error] [pid 1632] [client] PHP Fatal error: Uncaught PDOException: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "publication_galleys_pkey"\nDETAIL: Key (galley_id)=(31) already exists. in /var/www/ojs-3.3.0-8/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:115\nStack trace:\n#0 /var/www/ojs-3.3.0-8/lib/pkp/lib/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(115): PDOStatement->execute()\n#1 /var/www/ojs-3.3.0-8/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(464): Doctrine\\DBAL\\Driver\\PDOStatement->execute()\n#2 /var/www/ojs-3.3.0-8/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(664): Illuminate\\Database\\Connection->Illuminate\\Database\\{closure}()\n#3 /var/www/ojs-3.3.0-8/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(631): Illuminate\\Database\\Connection->runQueryCallback()\n#4 /var/www/ojs-3.3.0-8/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php(465): Illumin in /var/www/ojs-3.3.0-8/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 671, referer:

Steps I took leading up to the issue:

Dashboard → Issues → volume number → article title → Submission → Publication → Galleys → Add galley

Then here I fill the Label as “PDF” and then Save:

The problem happens after trying to save it.

Also, there isn’t any galley it seems:

What can I do about this, please?

What I tried to resolve the issue:

I don´t even know which table/place to look at :slight_smile:

Application Version - e.g., OJS 3.1.2:

OJS is 3.3.0-8

(OJS 3.2.0-3) DB Error: duplicate key value violates unique constraint "publication_galleys_pkey" - #5 by gabriellence did fix this issue:

SELECT max(galley_id) FROM publication_galleys;
ALTER SEQUENCE publication_galleys_galley_id_seq RESTART WITH *<maximum value>*;

This topic was automatically closed after 2 days. New replies are no longer allowed.