Duplicate key value violates unique constraint “workflow_statistics_pkey” still happening

Describe the problem/error/question

2023-08-11T13:22:12.725018441Z 2023-08-11 13:22:12.724 UTC [434] ERROR:  duplicate key value violates unique constraint "pk_workflow_statistics"
2023-08-11T13:22:12.725038734Z 2023-08-11 13:22:12.724 UTC [434] DETAIL:  Key ("workflowId", name)=(81, data_loaded) already exists.

Happening every sec…

I saw a topic on this but now readonly and no “real” solution. Any thought on this?

Thank you!

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.1.1
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: unkown

Hi @vbarrier, I am very sorry for this. This should have been fixed with 0.223 (refactor: Upsert workflow statistics to suppress unnecessary error messages by krynble · Pull Request #5863 · n8n-io/n8n · GitHub) but appears to have made a comeback. I’ll add this to our bug tracker for a closer look and fix.

Hi @vbarrier you can follow this bug. I think it will be fixed in the next version.


I’ve come across this thread because I’m encountering the exact same issue with duplicate insertions in the “workflow_statistics” table. Here’s an excerpt from my error log:

2023-10-21 08:20:46.201 UTC [XXXXX] ERROR:  duplicate key value violates unique constraint "pk_workflow_statistics"
2023-10-21 08:20:46.201 UTC [XXXXX] DETAIL:  Key ("workflowId", name)=(XXXXXXXXXXXX, data_loaded) already exists.
2023-10-21 08:20:46.201 UTC [XXXXX] STATEMENT:  INSERT INTO "public"."workflow_statistics"("count", "latestEvent", "name", "workflowId") VALUES ($1, $2, $3, $4)
... [similar lines continue]

It appears the same key is being attempted for insertion multiple times. Has anyone found a solution or received feedback from the n8n team regarding this? Any insights or workarounds would be greatly appreciated!

Thank you in advance.

Hey @Daradaal,

We are aware of this and have a dev ticket opened to fix it but at the moment as it doesn’t break anything the priority is fairly low. This will be fixed and hopefully before the end of the year.

Our of interest other than the extra log lines is this breaking anything for you?

New version [email protected] got released which includes the GitHub PR 7824.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.