ibmdb / node-ibm_db

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

Intermittant "SQL5005C The operation failed because the database manager failed to access either the database manager configuration file or the database configuration file." errors using connection pool. #861

Closed markddrake closed 1 year ago

markddrake commented 2 years ago

Target Db2 Server Version: 11.5.7 (Official IBM DB2 Docker container) node.js Version: 17.7.2 ibm_db version: 2.8.1

I am getting intermittent SQL5005C errors when using a connection pool to manage database connectivity.

The following error is reported:

DB2Error: [IBM][CLI Driver] SQL5005C  The operation failed because the database manager failed to access either the database manager configuration file or the database configuration file.bi/db2/db2QA.js:35:8) {
    error: '[ibm_db] SQL_ERROR',
    sqlcode: -5005,

If I simply catch the error and retry the operation it works. The code I am using to obtain the connection is shown below:

  let attemptReconnect = this.ATTEMPT_RECONNECTION;

    while (true) {

      this.SQL_TRACE.comment(`Gettting Connection From Pool.`)
      const sqlStartTime = performance.now()
      try  {
        const stack = new Error().stack
        const connection = await new Promise((resolve,reject) => {
          this.connectionPool.open(this.createConnectionString(),(err,conn) => {
            if (err) reject(new DB2Error(this.DRIVER_ID,err,stack,'DB2.Pool.getConnection()'))
            resolve(conn)
          })
        })
        return connection
      } catch(cause) {
        if (attemptReconnect && cause.lostConnection()) {
          attemptReconnect = false;
          // reconnect() throws cause if it cannot reconnect...
          await this.reconnect(cause,'SQL')
          continue;
        }
        throw this.trackExceptions(cause)
      }
    }

the DB2Error classes lostConnection() method that returns true if the sqlcode is -5005.

Any idea why this occuring and how to stop it...

bimalkjha commented 2 years ago

@markddrake The error SQL5005C is returned by the Db2 server and not the client. It report issues about database manager configuration file. Please contact the IBM Support with db2 traces to look into the issue. Thanks.

markddrake commented 2 years ago

Understood, however please note that I have only seen this error when using the connection pool. If I get a new connection every time I do not see the issue. BTW is there any way to dispose of a connection pool connection, so that it is closed rather than returned to the pool ?

bimalkjha commented 2 years ago

@markddrake To avoid connection going back to pool when closed, you can call conn.realClose() or conn.realCloseSync() APIs.

bimalkjha commented 1 year ago

image

We see this error on server. ibm_db is just returning the error message that it received from server. Hence, closing this issue. Thanks.