n8n-io / n8n

Free and source-available fair-code licensed workflow automation tool. Easily automate tasks across different services.
https://n8n.io
Other
47.18k stars 7.01k forks source link

ERROR: duplicate key value violates unique constraint #8436

Open davidloman opened 8 months ago

davidloman commented 8 months ago

Describe the bug I am encountering a unique constraint violation in the PostgreSQL database when running n8n version 1.25.1 inside a Docker container. Despite verifying that webhook entities have unique paths, the logs show attempts to insert duplicate webhook path data.

Logs

n8n_postgres | 2024-01-25 04:30:12.920 UTC [1] LOG: database system is ready to accept connections n8n_postgres | 2024-01-25 04:30:23.020 UTC [41] ERROR: duplicate key value violates unique constraint "PK_b21ace2e13596ccd87dc9bf4ea6" n8n_postgres | 2024-01-25 04:30:23.020 UTC [41] DETAIL: Key ("webhookPath", method)=(879706d6-9c58-4731-9a36-f495235de782, GET) already exists. n8n_postgres | 2024-01-25 04:30:23.020 UTC [41] STATEMENT: INSERT INTO "public"."webhook_entity"("workflowId", "webhookPath", "method", "node", "webhookId", "pathLength") VALUES ($1, $2, $3, $4, DEFAULT, DEFAULT) n8n_postgres | 2024-01-25 04:30:23.035 UTC [41] ERROR: duplicate key value violates unique constraint "PK_b21ace2e13596ccd87dc9bf4ea6" n8n_postgres | 2024-01-25 04:30:23.035 UTC [41] DETAIL: Key ("webhookPath", method)=(06463a74-5fa4-4112-86cb-f18a9d0f063e, POST) already exists. n8n_postgres | 2024-01-25 04:30:23.035 UTC [41] STATEMENT: INSERT INTO "public"."webhook_entity"("workflowId", "webhookPath", "method", "node", "webhookId", "pathLength") VALUES ($1, $2, $3, $4, DEFAULT, DEFAULT) n8n_worker | * Concurrency: 10

PostgreSQL Data

n8n=# SELECT * FROM webhook_entity; webhookPath | method | node | webhookId | pathLength | workflowId --------------------------------------+--------+---------+-----------+------------+------------------ 06463a74-5fa4-4112-86cb-f18a9d0f063e | POST | Webhook | | | rmW43szjQrvxsGBN 879706d6-9c58-4731-9a36-f495235de782 | GET | Webhook | | | BNrNU7gigUjh1Qsk (2 rows)

To Reproduce Steps to reproduce the behavior:

Run n8n 1.25.1 in a Docker container alongside PostgreSQL and Worker Configure two webhook entities with unique paths. Start the n8n instance. Observe the unique constraint violation error in the logs. Expected behavior I expected n8n to start and run without encountering a database unique constraint violation error.

Environment (please complete the following information):

OS: [e.g. Ubuntu Linux 22.04] n8n Version: [e.g. 1.25.1] Node.js Version: [e.g. 18.16.0] Database system: [e.g. PostgreSQL] Operation mode: [e.g. own; operation modes are own, main and queue. Default is main] Additional context During attempts to resolve this issue, webhook entities were checked for duplicate paths and none were found. The service has been restarted multiple times, yet the issue persists but server/service seems running OKAY.

Joffcom commented 8 months ago

Hey @davidloman,

Just to check are you using workers or webhook workers? Can you also confirm the version of Postgres you are using?

davidloman commented 8 months ago

Hey @davidloman,

Just to check are you using workers or webhook workers? Can you also confirm the version of Postgres you are using?

I am using webhook workers. The PostgreSQL version is 11

services: postgres: image: postgres:11 container_name: n8n_postgres

SpareShade commented 2 months ago

Hey peeps, is there any update on this. We are having the same issue, the hook seem to continually attempting to re-register itself... or something similar.