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
38 stars 23 forks source link

Space offset X'00000000' or X'FFFFFFFFFFFFFFFD' is outside current limit #88

Closed jorgecolonconsulting closed 4 years ago

jorgecolonconsulting commented 4 years ago

Sometimes calling certain procedures via this custom method executeStatement as such CALL PROCEDURE_NAME('val1'); will result in a segfault for node. It fails specifically at await statement.exec(sqlStatement);.

The job log shows the following error:

Space offset X'00000000' or X'FFFFFFFFFFFFFFFD' is outside current limit
   for object QP0ZSPWP  QSECOFR   200203.                               
 PASE for i ended for signal 11, error code 1.                          
 Value for call stack counter parameter not valid.                      
 Application error.  CPFB9C6 unmonitored by QP0ZPCPN at statement       
   0000000278, instruction X'0000'.

Environment details:

 executeStatement: async function(sqlStatement) {
    const conn = this.pool.attach();

    var statement, results;

    statement = new Statement(conn.connection);
    await statement.exec(`SET PATH = ` + libraryList.join(', '));
    await statement.close();

    statement = new Statement(conn.connection);
    results = await statement.exec(sqlStatement);

...
kadler commented 4 years ago

What's the SQL statement you are executing at the time? Or at least, can you give a description of the query (# of columns, column types and sizes, etc...)?

jorgecolonconsulting commented 4 years ago

Here's some additional information. This happens when calling procedures with exec after a certain amount of rows (around 750 in our case). Here's the description of the columns.

image image

We switched over to using execute() and fetch() to fetch row-by-row. After doing that, the segfault doesn't happen anymore.

kadler commented 4 years ago

@dmabupt can you investigate this failure?

dmabupt commented 4 years ago

This seems to be some resource overflow issue? I may add some checks in the code to identify. Hello @2upmedia , Does the sync version API execSync() return the same error?

github-actions[bot] commented 4 years ago

:wave: Hi! This issue has been marked stale due to inactivity. If no further activity occurs, it will automatically be closed.

soleradnb commented 2 years ago

Did anyone ever investigate this issue any further? I seem to having the same issue here when I call executeSync I'm calling a stored proc and the results are inconsistent. Sometimes it works, sometimes I get the segmentation fault. I can call the below code 3 or 4 times and it's fine, but then other times I get the segmentation error. I'm not sure what the problem is?

My code:


 let sql = "";

                if (env == "DEV") {
                    sql = 'CALL PGX320CD.PGDR589B(?,?,?,?,?,?,?,?,?,?,?,?)';
                } else if (env == "QA") {
                    sql = 'CALL PGX320CQ.PGDR589B(?,?,?,?,?,?,?,?,?,?,?,?)';
                } else if (env == "PROD") {
                    sql = 'CALL PGX320CP.PGDR589B(?,?,?,?,?,?,?,?,?,?,?,?)';
                };

                // Set the Input Parms 

                let product = "";
                let quantity1 = 0;
                let cost1 = 0;
                let quantity2 =  0;
                let cost2 =  0;
                let quantity3 =  0;
                let cost3 =  0;
                let quantity4 =  0;
                let cost4 =  0;
                let quantity5 =  0;
                let cost5 =  0;
                let messageOut = "";

                product = jsonObj.product;
                quantity1 = jsonObj.quantity.qty1;
                cost1 = jsonObj.cost.cost1;
                quantity2 = jsonObj.quantity.qty2;
                cost2 = jsonObj.cost.cost2;
                quantity3 = jsonObj.quantity.qty3;
                cost3 = jsonObj.cost.cost3;
                quantity4 = jsonObj.quantity.qty4;
                cost4 = jsonObj.cost.cost4;
                quantity5 = jsonObj.quantity.qty5;
                cost5 = jsonObj.cost.cost5;
                messageOut = "";

                let params = [
                    product, 
                    quantity1,
                    cost1,
                    quantity2,
                    cost2,
                    quantity3,
                    cost3,
                    quantity4,
                    cost4,
                    quantity5,
                    cost5,
                    messageOut
                ];

                console.log(params);

                statement.prepareSync(sql,(err)=>{
                    if (err) {
                    console.log(err);
                    };
                });

                statement.bindParametersSync(params, (err)=>{
                    if (err) {
                    console.log(err);
                    };
                });

                statement.executeSync((outputParams, err)=>{
                    if (err) {
                    console.log('PGDR589: ' + err);
                    } else {
                    console.log('Params = ' + outputParams);
                    statement.close();
                    connection.disconn();
                    connection.close();
                    callback(outputParams);
                    };
                });`

My Stored Proc:

CREATE OR REPLACE PROCEDURE &LIB/PGDR589B (
 IN     PRODUCT         VARCHAR(33),
 IN     QTY1            NUMERIC(15,3),
 IN     COST1           NUMERIC(17,4),
 IN     QTY2            NUMERIC(15,3),
 IN     COST2           NUMERIC(17,4),
 IN     QTY3            NUMERIC(15,3),
 IN     COST3           NUMERIC(17,4),
 IN     QTY4            NUMERIC(15,3),
 IN     COST4           NUMERIC(17,4),
 IN     QTY5            NUMERIC(15,3),
 IN     COST5           NUMERIC(17,4),
 OUT    MESSAGE         VARCHAR(500)
 )
 LANGUAGE RPGLE
 SPECIFIC &LIB/PGDR589B
 NOT DETERMINISTIC
 CALLED ON NULL INPUT
 EXTERNAL NAME PGDR589B
 PARAMETER STYLE GENERAL ;

COMMENT ON SPECIFIC PROCEDURE &LIB/PGDR589B
 IS 'Purchase Price API' ;  

the message:

Message . . . . : Space offset X'00000000' or X'69636520656E748A' is outs current limit for object QP0ZSPWP MATTOJ 215693.
Cause . . . . . : A program tried to set a space pointer, tried to use
storage outside a space, or tried to use an unallocated page in teraspace The space class is X'08'. The space class designates the type of space:

When I add the debugger, I can see that this happens after the execute function:

SQLExecute(0):
SQLNumResultsCols(0) Has Results
/nodejs/webapi/app.sh[21]: 19066 Segmentation fault(coredump)