How to use maapi_request_action_th

Hi,

Can anyone please tell me how can we use below function to use transaction in action callpoint.

int maapi_request_action_th(int sock, int thandle, confd_tag_value_t
*params, int nparams, confd_tag_value_t **values, int *nvalues, const
char *fmt, …);

Regards,
Anup Agrawal

Hi,

maapi_request_action_th() is used to invoke an action. It is not normally used from an action callpoint that was called because an action was invoked.

See the confd_lib_dp(3) man page for details.

Hi cohult,

thanks for the response.
If i want to start the write transaction from action callpoint which steps i need to follow. Because, when i am trying to start normal CDB_RUNNING session, Confd getting stuck on apply_transaction function.

Below process i followed to start transaction from action callpoint,
/* Session creation */
CDA_CONFD_FATAL(CDA_maapi_start(CDB_RUNNING, &th, IMMEDIATE));
CDA_maapi_set_namespace(th, core_model__ns);

     maapi_ret = CDA_maapi_exists(th, CORE_MODEL_FD_FC, vlanFd_uuid, vlanFc_uuid);

     if(CONFD_TRUE != maapi_ret)
     {
         CDA_CONFD_FATAL(CDA_maapi_create(th, CORE_MODEL_FD_FC, vlanFd_uuid, vlanFc_uuid));
         CDA_CONFD_FATAL(CDA_maapi_cd(th, CORE_MODEL_FD_FC, vlanFd_uuid, vlanFc_uuid));

         /* set the vlan-fc local id */
         CDA_SET_STR(&vt, vlanFc_localId);
         CDA_CONFD_FATAL(CDA_maapi_set_elem(th, &vt, CORE_MODEL_LOCAL_ID_ENT));

     }
     else
     {
         printf("RPC instance for given vlan ID already exists");
     }

     CDA_CONFD_FATAL(CDA_maapi_apply_trans(th));
     CDA_CONFD_FATAL(CDA_maapi_end(th));

Regards,
Anup

Hi,

Start a separate thread/process that perform the transaction if your action handler thread also handle subscriptions or other callpoints triggered by the commit (apply).

Regards

Hi Cohult,

What if the action handler is expected to reply a value based on DB commit success.

As pee the above suggestion , it is expected to open a separate thread to perform commit (the configuration)

Please share further inputs.

Regards,
Chandra

hi All,

Can anyone help on the above query?

I tried to use confd_cmd tool from action handler (as it will work like a new process), again it halts at MAAPI_APPLY_TRANS

Below are confd_cmd trace logs
TRACE Connected (maapi) to ConfD
TRACE MAAPI_START_USER_SESSION → CONFD_OK
TRACE MAAPI_START_TRANS → CONFD_OK
TRACE MAAPI_CREATE /temp/container-1/list{60} → CONFD_OK
TRACE MAAPI_SET_ELEM2 /temp/container-1/list{60}/Rowstatus → CONFD_OK
TRACE MAAPI_APPLY_TRANS

Regards,
Chandrakanth S.

There is likely a deadlock. ConfD is waiting for your thread to reply to for example a transaction subscription notification or some other callback invocation inside the transaction lock, while you are starting a transaction that will wait for that transaction to finish before continuing.

hi Cohult,

Thanks for the reply
Can you please help on comment 4/7 ?

Regards,
Chandrakanth S.

I suggest looking into the ConfD developer log (log level trace) which will tell what the ConfD transaction manager is doing at the time of the MAAPI apply.