title: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?
body: <p>I am using the following code to make a knex connection, but frequently the error occurred </p>
  
  <blockquote>
    <p>Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?  </p>
  </blockquote>
  
  <p>Can anyone please suggest the solution for this issue? </p>
  
  <pre><code>var knexConn = reqKnex({
          client: pClient,
          native: false,
          connection: pConn,
          searchPath: pSearchPath,
          pool: {
              max: 7,
              min: 3,
              acquireTimeout: 60 * 1000
          }
      });
  
  
  function getTransactionScope(pKnex, callback) {
      try {
          pKnex.transaction(function(trx) {
              return callback(trx);
          });
      } catch (error) {
          console.log(error);
      }
  }
  
  function ExecuteSQLQuery(pTranDB, pTrx, pQuery, pCallback) {
      try {
          var query = pTranDB.raw(pQuery);
  
          if (pTrx) {
              query = query.transacting(pTrx);
          }
          query.then(function(res, error) {
              try {
                  if (error) {
                      console.log(error);
                  } else {
                      return pCallback(res, error);
                  }
              } catch (error) {
                  console.log(error);
              }
          }).catch(function(error) {
              return pCallback(null, error);
          });
      } catch (error) {
          console.log(error);
      }
  }
  
  function Commit(pTrx, pIsCommit) {
      try {
          if (pIsCommit) {
              pTrx.commit();
          } else {
              pTrx.rollback();
          }
      } catch (error) {
          console.log(error);
      }
  }
  </code></pre>