How to use maapi_unlock api when CDB is locked

CDB is in locked state.
Tried to unlock the CDB using a cc application which does the following in sequence when db is in locked state:

  1. maapi_connect - successful
  2. maapi_start_user_session - successful
  3. maapi_unlock - fails with MAAPI_UNLOCK DEBUG external error —> CONFD_ERR.

Note that maapi_lock/unlock does not lock CDB itself, rather it control write access to the datastore (CDB or external DB) from northbound agents, e.g. MAAPI, NETCONF, CLI etc. See ConfD UG “Global locks”

Regarding the error message, from the confd_lib_maapi(3) man page:

If confd_errno is CONFD_ERR_EXTERNAL it means that a callback has been invoked in an external database to lock/unlock which in its turn returned an error. (See confd_lib_dp(3) for external database callback API)