Postgres node - Called end on pool more than once

Describe the problem/error/question

I checked the forum and the closest I could find on my specific error was this: Serious error in postgres node

That is not exactly what we get. Most of the time node works perfectly, but sometimes the Postgres node drops an error: Called end on pool more than once (I can’t replicate that error manually). Maybe someone has seen this and/or can help me with this?

What is the error message (if any)?

Information on your n8n setup

  • n8n version: 1.6.1
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
1 Like

I tried to delete old node and add new Postgres node, still the same error

Hi @Emils_Bisenieks, this sounds rather unexpected to me and I was not able to reproduce this on my end based on your description.

Are you using anything other than just raw n8n and Postgres, for example something like PgBouncer?

Hi @MutedJam.
We don’t use anything extra.
We do use PostgreSQL outside of n8n docker, and n8n uses docker local subnet to connect

Hm, I wonder if this could be a network problem despite the error message. Are you also seeing this problem when enabling retries on your Postgres node?

1 Like

@MutedJam I have set that up now and check. As I cant replicate that manually, I have to wait for real cases to come through. I will let you know soon!

1 Like

Hey @MutedJam! I have monitored the workflow and that error hasn’t appeared after I enabled “Retry On Fail”. Thank you!

1 Like

Hi everyone, I continue to have the same problem despite having set the retry flag.

I have over 40 scenarios with postgresql modules and they are all giving me the same problem, I’m going crazy

Please help me. After updating to 1.7.1 I still have this problem

Error Stack:

Error: Called end on pool more than once
    at BoundPool.end (/usr/local/lib/node_modules/n8n/node_modules/pg-pool/index.js:441:19)
    at BoundPool.Database.pool.end (/usr/local/lib/node_modules/n8n/node_modules/pg-promise/lib/database.js:133:31)
    at Object.router (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Postgres/v2/actions/router.js:62:24)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:658:19)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:631:53

Furthermore, in most of my scenarios, I have a first Postgresql module that performs a delete on the table, and then a second that performs an insert: the insert fails for duplicated key, and the reason is that the table is not empty. This means that the first delete is not actually executed (I also tried with truncate instead of delete, but I have the same problem).

The proof that the first step is not executed when the scenario is scheduled is that if I execute it manually, everything goes fine (same data in the database).
This situation creates big problems for me since the errors are random (sometimes they happen and sometimes they don’t).

It almost seems that the problem arose when the “Execution Order:” option was introduced.

I’m also seeing this. I’m using the free elephantsql tier.

I’m looping but it even happens when I put in a delay of 10 seconds. Same error - so can’t really contribute with much more here:

Error: Called end on pool more than once
    at BoundPool.end (/app/code/node_modules/pg-pool/index.js:441:19)
    at BoundPool.Database.pool.end (/app/code/node_modules/pg-promise/lib/database.js:133:31)
    at Object.router (/app/code/node_modules/n8n-nodes-base/nodes/Postgres/v2/actions/router.ts:61:18)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Workflow.runNode (/app/code/node_modules/n8n-workflow/src/Workflow.ts:1284:8)
    at /app/code/node_modules/n8n-core/src/WorkflowExecute.ts:1018:29

Hey :wave:

I’m also getting the same error.

Adding Retry On Fail seems to have reduce the number of fail. But I’m still getting few of them.

Note that I’m connecting to a Clickhouse DB using postgres node, so that could the reason.

I installed the last version 1.8.2, but I still got the problem… @MutedJam please let us know thank you

Same issue here, had to add retries to make it work

Can you share a workflow that is triggering this issue?

let me know how to share it… thanks @Jon

I recorded a video… It just happened. It’s so weird because the error occurs randomly. And if I run it manually it works!

same is not occuring with the old postgres nodes, (prior v1.0.0)

Hey @tool_dmvf_ltd,

If you select the nodes you can copy / paste them here and we can see if it can be reproduced.

Hi @Jon is useless to copy/paste the nodes here, because it’s impossible to reproduce the error… it’s random . Please take a look at my posted video in the prev post, thanks