Skip to content

generic-pool "Resource not currently part of this pool" exceptions for mssql #8098

Closed

Description

What you are doing?

I'm creating my Sequelize instance with the following options:

const db_options =  {
     name: Config.DB_NAME, 
     username: Config.DB_USERNAME, 
     password, 
     host: Config.DB_HOST,
     dialect: "mssql",
     dialectOptions: {
         encrypt: true
     },
     pool: {
         min: 10,
         max: 300,
         idle: 30000,
     },
     benchmark: true
     logging: true
};

What do you expect to happen?

No issues at all

What is actually happening?

It seems like connections are dying before they are returned to the pool. The following exception is thrown quite often:

Error: Resource not currently part of this pool 
    at Pool.destroy (/data/node_modules/generic-pool/lib/Pool.js:450:35) 
    at Connection.connection.on.err (/data/node_modules/sequelize/lib/dialects/mssql/connection-manager.js:124:25) 
    at emitOne (events.js:96:13) at Connection.emit (events.js:188:7) 
    at Connection.socketError (/data/node_modules/tedious/lib/connection.js:703:14) 
    at emitOne (events.js:101:20) at Socket.emit (events.js:188:7) 
    at emitErrorNT (net.js:1278:8) at _combinedTickCallback (internal/process/next_tick.js:74:11) 
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Dialect: mssql
Database version: V12
Sequelize version: 4.4.2

Activity

  1. mhuggins commented on Aug 20, 2017

    @mhuggins

    I'm seeing a similar issue, but with Pool.release:

    Unhandled rejection Error: Resource not currently part of this pool
        at Pool.release (/Users/mhuggins/Development/bittrex-monitor/node_modules/generic-pool/lib/Pool.js:422:35)
        at ConnectionManager.releaseConnection (/Users/mhuggins/Development/bittrex-monitor/node_modules/sequelize/lib/dialects/abstract/connection-manager.js:292:22)
        at Transaction.cleanup (/Users/mhuggins/Development/bittrex-monitor/node_modules/sequelize/lib/transaction.js:165:50)
        at sequelize.getQueryInterface.rollbackTransaction.finally (/Users/mhuggins/Development/bittrex-monitor/node_modules/sequelize/lib/transaction.js:95:23)
    From previous event:
        at Transaction.rollback (/Users/mhuggins/Development/bittrex-monitor/node_modules/sequelize/lib/transaction.js:93:15)
        at connectionPromise.then.then.then.then.then.catch.setupErr (/Users/mhuggins/Development/bittrex-monitor/node_modules/sequelize/lib/transaction.js:123:31)
        at runCallback (timers.js:781:20)
        at tryOnImmediate (timers.js:743:5)
        at processImmediate [as _immediateCallback] (timers.js:714:5)
    From previous event:
        at Transaction.prepareEnvironment (/Users/mhuggins/Development/bittrex-monitor/node_modules/sequelize/lib/transaction.js:123:13)
        at Sequelize.transaction (/Users/mhuggins/Development/bittrex-monitor/node_modules/sequelize/lib/sequelize.js:952:43)
        at Tracker._callee5$ (/Users/mhuggins/Development/bittrex-monitor/build/tracker/index.js:225:41)
        at tryCatch (/Users/mhuggins/Development/bittrex-monitor/node_modules/regenerator-runtime/runtime.js:65:40)
        at Generator.invoke [as _invoke] (/Users/mhuggins/Development/bittrex-monitor/node_modules/regenerator-runtime/runtime.js:303:22)
        at Generator.prototype.(anonymous function) [as next] (/Users/mhuggins/Development/bittrex-monitor/node_modules/regenerator-runtime/runtime.js:117:21)
        at step (/Users/mhuggins/Development/bittrex-monitor/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
        at /Users/mhuggins/Development/bittrex-monitor/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
        at Promise (<anonymous>)
        at F (/Users/mhuggins/Development/bittrex-monitor/node_modules/core-js/library/modules/_export.js:35:28)
        at Tracker.<anonymous> (/Users/mhuggins/Development/bittrex-monitor/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12)
        at Tracker.saveCandles (/Users/mhuggins/Development/bittrex-monitor/build/tracker/index.js:269:20)
        at Tracker._callee3$ (/Users/mhuggins/Development/bittrex-monitor/build/tracker/index.js:142:40)
        at tryCatch (/Users/mhuggins/Development/bittrex-monitor/node_modules/regenerator-runtime/runtime.js:65:40)
        at Generator.invoke [as _invoke] (/Users/mhuggins/Development/bittrex-monitor/node_modules/regenerator-runtime/runtime.js:303:22)
        at Generator.prototype.(anonymous function) [as next] (/Users/mhuggins/Development/bittrex-monitor/node_modules/regenerator-runtime/runtime.js:117:21)
        at step (/Users/mhuggins/Development/bittrex-monitor/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
        at /Users/mhuggins/Development/bittrex-monitor/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
        at <anonymous>
        at process._tickCallback (internal/process/next_tick.js:188:7)
    
  2. dylandechant commented on Aug 23, 2017

    @dylandechant

    also seeing this with mssql
    4.6.0

  3. tylerjwatson commented on Aug 28, 2017

    @tylerjwatson
    Contributor

    There is a PR to generic-pool which is supposed to prevent this from happening. See coopernurse/node-pool#201

    This is a huge issue for us as it is delaying us going to production on our software. It only happens when running in remote cloud environments. I am going to manually apply this patch on our nightly environments and see if we get a bit more stability.

  4. maxsommer commented on Sep 11, 2017

    @maxsommer

    Also seeing the issue @mhuggins has with mysql on Sequelize 4.8.2
    As far as I can tell the PR to generic-pool that is supposed to fix it is not helping.

    UPDATE: generic-pool has been updated to a new version that is supposed to fix this, however I cannot confirm that it's fixed (at least for the error @mhuggins and me are experiencing) – I still get the error

    Unhandled rejection Error: Resource not currently part of this pool
    at Pool.release (/api/node_modules/generic-pool/lib/Pool.js:426:35)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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