ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
190 stars 151 forks source link

question on SQL30081N #810

Closed huineng closed 2 years ago

huineng commented 2 years ago

we have an openshift app having 3 replicas , we are using the latest ibm_db package we are using pool and initializing it with

ibmdb: new Pool({
                maxPoolSize: 50,
                connectTimeout: 40,
                autoCleanIdle: false,
                idleTimeout: 54000,
            }),

The application works as designed, but occasionally, after some time of inactivity (no user running reports) we do get (ibm db2 warehouse on cloud)

Error: [IBM][CLI Driver] SQL30081N  A communication error has been detected. Communication protocol being used: "TCP/IP".  Communication API being used: "SOCKETS".  Location where the error was detected: "xxxxx".  Communication function detecting the error: "selectForRecvTimeout".  Protocol specific error code(s): "115", "", "".  SQLSTATE=08001

question, are the above the best settings for a pool. I assume active connections are being kept in the pool but then when used , are no longer active. (stale ?)

what kind of code should i apply , should i ignore these errors ?

i see the following in the code

if(self.realClose){
    if((err && err['message'] && err['message'].search("SQL30081N") != -1))
    {
      // Close all connections in availablePool as all are invalid now
      // It will be removed from available pool on next pool.open for connected=false
      self.closeSync();  //Move connection from usedPool to availablePool
      var availablePool = self.pool.availablePool[self.connStr];
      if (availablePool && availablePool.length) {
        for (var i = 0, len = availablePool.length; i < len; i++) {
          availablePool[i].realCloseSync();
        }
      }
      self.realCloseSync();
    }
  }

does this mean the library will try another connection ? and in fact no real error is returned to the user ?

some guidance would be appreciated

thanks

bimalkjha commented 2 years ago

@huineng The SQL30081N error after some time of inactivity tells that the existing connection is closed by server and these connections are no longer valid. Yes, the shared code will clean all connections from pool and on next request for pool.open() will go for new connection. Only thing is after getting SQL30081N error, application should retry the same operation which returned SQL30081N and next action would complete without error. Basically, SQL30081N error tells that connection is invalid and need to retry the operation. Retry should work and error should disappear. Hope it explains. Thanks.

huineng commented 2 years ago

yes, this is what i thought , and i will look for an implementation for this

thanks