Skip to content

Keep connection pool alive #108

@negreanucalin

Description

@negreanucalin

I have made an express server and noticed that when the Pool is not being used for ~30 minutes an error spring up:

this.pool = new Pool({
    max: process.env.V_POOL_SIZE,
    idleTimeoutMillis: 0,
    connectionTimeoutMillis:0,
    allowExitOnIdle:false,
    host
});

Stack trace

/usr/src/app/node_modules/vertica-nodejs/lib/client.js:203
const error = this._ending ? new Error('Connection terminated') : new Error('Connection terminated unexpectedly')
                                                                        ^
Error: Connection terminated unexpectedly
    at Connection.<anonymous> (/usr/src/app/node_modules/vertica-nodejs/lib/client.js:203:73)
    at Object.onceWrapper (node:events:627:28)
    at Connection.emit (node:events:513:28)
    at Connection.emit (node:domain:489:12)
    at Socket.<anonymous> (/usr/src/app/node_modules/vertica-nodejs/lib/connection.js:181:12)
    at Socket.emit (node:events:525:35)
    at Socket.emit (node:domain:489:12)
    at endReadableNT (node:internal/streams/readable:1358:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Is there a way to prevent this? (listen to an event and reconnect, disable auto-closing connections or catch and reconnect)

Dependencies:

    "@types/express": "^4.17.15",
    "@types/jest": "^29.2.1",
    "@types/node": "^18.11.9",
    "@types/pg-copy-streams": "^1.2.1",
    "date-fns": "^2.29.3",
    "dotenv": "^16.0.3",
    "express": "^4.18.2",
    "jest": "^29.2.2",
    "kafkajs": "^2.2.3",
    "logform": "^2.4.2",
    "moment": "^2.29.4",
    "mysql2": "^2.3.3",
    "nodemon": "^2.0.20",
    "pg-copy-streams": "^6.0.4",
    "ts-command-line-args": "^2.3.1",
    "ts-jest": "^29.0.3",
    "ts-node": "^10.9.1",
    "typescript": "^4.8.4",
    "vertica-nodejs": "^1.0.1",
    "winston": "^3.8.2"

Versions
Node v16.19.0
Vertica 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions