IBM / nodejs-idb-connector

A JavaScript (Node.js) library for communicating with Db2 for IBM i, with support for queries, procedures, and much more. Uses traditional callback-style syntax
MIT License
37 stars 23 forks source link

dbconn.conn() Fails with SQLCODE -952 #72

Closed DavidRusso closed 5 years ago

DavidRusso commented 5 years ago

I use idb-connector in my package. I have run into a problem on a customer system where it fails to connect to the *LOCAL database.

The relevant code is like this:

var db2i = require("idb-connector"); var dbconn = new db2i.dbconn(); dbconn.conn("*LOCAL"); It fails at dbconn.conn(), with this: ` /profoundjs/node_modules/profoundjs/profound.jse:138 dbconn.conn("*LOCAL"); ^

Error: SQLSTATE=57014 SQLCODE=-952 Processing of the SQL statement ended. Reason code 0. ` Looking at the message description SQL0952 in QSQLMSG shows that reason code 0 is 'Unknown Cause'.

What could cause this? We have many customers running this same code, and I've never seen it fail like this before.

The customer is running Node 8 on IBM i 7.3.

dmabupt commented 5 years ago

Hello @DavidRusso , I can not reproduce the error on my 7.3 systems. If you have such an environment, would you tell me the detailed steps? From the search result on internet, this message seems related to timeout issue. Maybe we need to consult some Db2 experts.

DavidRusso commented 5 years ago

The steps to recreate are just running those 3 lines of code above. But, as I mentioned, the problem is only occurring on one particular customer's system. We had a look around on this system and determined that it's some type of authority/permissions issue...

We noticed that the problem was only occurring when a certain user profile runs the code -- it works fine when other users run the code. The failing user is set up as class USER and without any special authorities. We modified this user profile and added ALLOBJ special authority, and the problem went away.

So, obviously we don't want the user to have ALLOBJ authority, but this shows that it's an authority problem of some kind on this system. I have never run into this before -- we have many, many customers who are running this code without the need for ALLOBJ. So, the question is, what exactly does the user need authority to in order to run dbconn.conn("*LOCAL) ?

ThePrez commented 5 years ago

This looks like a CLI issue. I think the IBM i support team for CLI should take the next look at this. Please open a PMR and reference this issue.

Didier68 commented 5 years ago

Hi, I have the same issue with my customer, when running the idb connector, when calling dbconn.conn('*LOCAL', userId, passwd);

SQLSTATE=57014 SQLCODE=-952 Traitement de l'instruction SQL arrêté. Code raison : 0. (same message than @DavidRusso , in french)

Is there a solution ?

DavidRusso commented 5 years ago

I was able to solve the problem for my customer. The connection was failing because the system was trying to add libraries to the list that our server user profile was not authorized to. It was picking up these libraries from the server user profile's job description.

kadler commented 5 years ago

Seems like the error message/reporting could use some improvement.

Didier68 commented 5 years ago

Thank you @DavidRusso , now it's good... Error documentation:

The problem is a result of the user profile having a job description that no longer exists. It seems that Query is tolerant of this situation, but Warehouse Manager and Warehouse Builder are not. There may be other causes to this problem, and it's best to follow the same procedure to make sure. We found the problem by displaying the QSQSRVR job log associated with the connection. Use the following to accomplish this:

  1. Increase logging for QSQSRVR jobs with this command: CHGJOBD JOBD(QGPL/QDFTSVR) LOG(4 00 SECLVL) LOGCLPGM(YES) LOGOUTPUT(*JOBEND)