简体   繁体   中英

How to manage connection pool with Knex/generic-pool and Oracle

We use Knex with generic pool as our Query Builder and Pool Manager for our Oracle 11.2 Database.

The problem we are facing is that some time Knex / generic-pool starts to accumulate connections and cant recycle them.

I tried to pass some parameters to Knex / Generic Pool to make them kill connections after some point, but looks like it did not worked out.

Packges version:

  • Knex: v0.13.0
  • Oracledb: v1.13.1
  • Generic Pool: v2.5.4

Knex configuration:

{
    client: 'oracledb',
    connection: {
        user: DB_USER,
        password: DB_PASSWORD,
        host: `${DB_HOST}:${DB_PORT}`,
        database: DB_NAME
    },
    debug: true,
    fetchAsString: ['number', 'clob'],
    acquireConnectionTimeout: 843600000,
    pool: {
        min: 2,
        max: 150,
        acquireTimeoutMillis: 100000,
        evictionRunIntervalMillis: 120000,
        maxWaitingClients: 100,
        idleTimeoutMillis: 100000
    }
}

Openshift print with environment variable DEBUG="Knex:*" showing a lot of clients waiting for connection

Try knex 0.14.2 some pool related problems were fixed in that. Also try to add some debug information when transactions are created/committed/rolled back. Open transactions will take connection from pool and does bot release it until transaction is ended. You can get information about pool and transacions bu running app with DEBUG=knex:* environment variable set.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM