ibm-messaging / mq-mqi-nodejs

Calling IBM MQ from Node.js - a JavaScript MQI wrapper
Apache License 2.0
79 stars 42 forks source link

SIGSEGV on close queue #114

Closed monel-mason closed 3 years ago

monel-mason commented 3 years ago

Hi,

We have got a problem when we try to close a queue, commenting the close queue line before disconnect seems to fix the problem

from sigsegv handler:

PID 21569 received SIGSEGV for address: 0x7f7f00000011
/home/dwh_node/node/flow-1/back/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x2cc1)[0x7f7f49762cc1]
/home/dwh_node/mqlib/lib64/libmqe_r.so(+0x452b87)[0x7f7f49fbfb87]
/home/dwh_node/mqlib/lib64/libmqe_r.so(+0x453a4a)[0x7f7f49fc0a4a]
/lib64/libpthread.so.0(+0xf630)[0x7f7f6442e630]
node[0x9b8f4d]
node[0xcefa10]
node(_ZN2v88internal13GlobalHandles40InvokeSecondPassPhantomCallbacksFromTaskEv+0xe8)[0xcf0578]
node(_ZThn32_N2v88internal14CancelableTask3RunEv+0x3b)[0xc6a96b]
node(_ZN4node22PerIsolatePlatformData17RunForegroundTaskESt10unique_ptrIN2v84TaskESt14default_deleteIS3_EE+0xc4)[0xa71704]
node(_ZN4node22PerIsolatePlatformData28FlushForegroundTasksInternalEv+0x249)[0xa73569]
node[0x1379a66]
node[0x138c545]
node(uv_run+0x138)[0x137a398]
node(_ZN4node16NodeMainInstance3RunEv+0x244)[0xa438d4]
node(_ZN4node5StartEiPPc+0x115)[0x9d1735]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f7f64073555]
node[0x96971c]

our node function code:

executeStep: async function (_userData, flow, step) {
    const _procedureName = "executeStep";
    logger.info(_fileName + ":" + _procedureName, {
      user: _userData,
      flow,
      step,
    });

   try {
      var cno = new mq.MQCNO();
      cno.Options |= mq.MQC.MQCNO_CLIENT_BINDING;
      var cd = new mq.MQCD();
      cd.ConnectionName = config.MQ.connstring
      cd.ChannelName = config.MQ.channel;
      cno.ClientConn = cd;
      if (mq.MQC.MQCNO_CURRENT_VERSION >= 7) {
        cno.ApplName = config.MQ.application;
      }
      var conn = await mq.ConnxPromise(config.MQ.queuemanager, cno);
      var od = new mq.MQOD();
      od.ObjectName = config.MQ.queue;
      od.ObjectType = mq.MQC.MQOT_Q;
      var openOptions = mq.MQC.MQOO_OUTPUT;
      var queue = await mq.OpenPromise(conn, od, openOptions);
      var mqmd = new mq.MQMD();
      var pmo = new mq.MQPMO();
      var cmho = new mq.MQCMHO();
      pmo.Options =
        mq.MQC.MQPMO_NO_SYNCPOINT |
        mq.MQC.MQPMO_NEW_MSG_ID |
        mq.MQC.MQPMO_NEW_CORREL_ID;
      var messHandler = await new Promise((res, rej) => {
        mq.CrtMh(conn, cmho, function (err, mh) {
          if (err) {
            logger.error(_fileName + ":" + _procedureName, {
              user: _userData,
              err,
            });
            rej(err);
          } else {
            var smpo = new mq.MQSMPO();
            var pd = new mq.MQPD();
            mq.SetMp(conn, mh, smpo, "TIPO_MESSAGGIO", pd, step.propertyMQ);
            res(mh);
          }
        });
      });
      pmo.OriginalMsgHandle = messHandler;
      var params = await db.getParameters(_userData, flow);
      var msg;
      if (step.messageMQ.includes("%%END_DATE_COMPACT%%"))
        msg = step.messageMQ.replace(
          "%%END_DATE_COMPACT%%",
          dateFormat(params.rows[0].t_end, "yyyymmdd")
        );
      if (step.messageMQ.includes("%%START_DATE_COMPACT%%"))
        msg = step.messageMQ.replace(
          "%%START_DATE_COMPACT%%",
          dateFormat(params.rows[0].t_start, "yyyymmdd")
        );
      if (step.messageMQ.includes("%%END_DATE%%"))
        msg = step.messageMQ.replace(
          "%%END_DATE%%",
          dateFormat(params.rows[0].t_end, "yyyy-mm-dd")
        );
      if (step.messageMQ.includes("%%START_DATE%%"))
        msg = step.messageMQ.replace(
          "%%START_DATE%%",
          dateFormat(params.rows[0].t_start, "yyyy-mm-dd")
        );
      await mq.PutPromise(queue, mqmd, pmo, msg);
//COMMENTING THE FOLLOWING ROW "FIXES" THE PROBLEM
      await mq.ClosePromise(queue, 0);
      await mq.DiscPromise(conn);
      return { result: "OK", message: "Messaggio MQ inviato" };
    } catch (err) {
      logger.error(_fileName + ":" + _procedureName, {
        user: _userData,
        error:err.message,
      });
      return ({ result: "KO", message: err.message });
    }
  },

node version:

[dwh_node@wpnode1 back]$ node -v
v14.15.0

our mq version:


mq version:
`-bash-4.1$ dspmqver -i
Name:        WebSphere MQ
Version:     7.5.0.9
Level:       p750-009-180830
BuildType:   IKAP - (Production)
Platform:    WebSphere MQ for Linux (x86-64 platform)
Mode:        64-bit
O/S:         Linux 2.6.32-754.el6.x86_64
InstName:    Installation1
InstDesc:    
Primary:     Yes
InstPath:    /opt/mqm
DataPath:    /var/mqm
MaxCmdLevel: 750
LicenseType: Production```
monel-mason commented 3 years ago

After a system update we felt upon #108 I reverted to node 14.4 as seen in the reference to issue 32463 on node Right now i don't see the problem anymore

ibmmqmet commented 3 years ago

That crash doesn't look identical to #108 but I wouldn't be surprised to find it's got the same root cause. There does seem to be some further recent work going on in the ref-napi project - issues and PRs - so maybe something will be available to help.

monel-mason commented 3 years ago

Hi Mark,

Maybe i wasn't so clear in the exposition. The first problem disappeared after an update of centos 7.9, our server linux distro. After that we had a new sigsegv, identical to #108 In other words now we can't replicate the issue exposed on my first post due to the change of system libs.

Right now, after using node 14.4 we don't see further errors, the code runs daily.

ibmmqmet commented 3 years ago

closing this as a dup of #108, and see my latest comment in there