During q transfer when new node is opening the q, msgnd fails to create the
runtime IMM object for the queue, and the open fails.

When the transfer is done, the old side and owner of the runtime object doesn't
delete the IMM object until after the q transfer response is sent. This is a
race condition. If the new side tries to create the runtime object before the
old side has deleted it, the opening of the queue on the new side fails.

Delete the runtime object before sending the q transfer response.
---
 src/msg/msgnd/mqnd_proc.c | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)

diff --git a/src/msg/msgnd/mqnd_proc.c b/src/msg/msgnd/mqnd_proc.c
index ca7dfc8ff..3205d714b 100644
--- a/src/msg/msgnd/mqnd_proc.c
+++ b/src/msg/msgnd/mqnd_proc.c
@@ -468,6 +468,21 @@ reg_req:
                asapi_msg_free(&opr.info.msg.resp);
 
 send_rsp:
+       /*
+        * Delete the runtime object before responding, otherwise the other side
+        * might create it before we have removed it
+        */
+       rc = immutil_saImmOiRtObjectDelete(cb->immOiHandle,
+                       &qnode->qinfo.queueName);
+
+       if (rc != SA_AIS_OK) {
+               LOG_ER("immutil_saImmOiRtObjectDelete: Deletion of MsgQueue "
+                               "object %s failed: %i",
+                               qnode->qinfo.queueName.value,
+                               rc);
+               return NCSCC_RC_FAILURE;
+       }
+
        /* Send the response */
        transfer_rsp.type = MQSV_EVT_MQP_RSP;
        transfer_rsp.msg.mqp_rsp.type = MQP_EVT_TRANSFER_QUEUE_RSP;
@@ -485,18 +500,23 @@ send_rsp:
        transfer_rsp.msg.mqp_rsp.error = err;
 
        rc = mqnd_mds_send_rsp(cb, &req->sinfo, &transfer_rsp);
-       if (rc != NCSCC_RC_SUCCESS)
+       if (rc != NCSCC_RC_SUCCESS) {
                TRACE_2(
                    "Queue Attribute get :Mds Send Response Failed %" PRIx64,
                    cb->my_dest);
-       else
-           /* delete Message Queue Objetc at IMMSV */
-           if (immutil_saImmOiRtObjectDelete(
-                   cb->immOiHandle, &qnode->qinfo.queueName) != SA_AIS_OK) {
-               LOG_ER(
-                   "immutil_saImmOiRtObjectDelete: Deletion of MsgQueue object 
%s",
-                   qnode->qinfo.queueName.value);
-               return NCSCC_RC_FAILURE;
+
+               /* readd the runtime object which was deleted above */
+               err = mqnd_create_runtime_MsgQobject(
+                               (char *)qnode->qinfo.queueName.value,
+                               qnode->qinfo.creationTime,
+                               qnode,
+                               cb->immOiHandle);
+
+               if (err != SA_AIS_OK) {
+                       LOG_ER("failed to recreate IMM q object for %s: %i",
+                                       qnode->qinfo.queueName.value,
+                                       err);
+               }
        }
 
        if (mqsv_message_cpy)
-- 
2.13.6


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to