Retry if ccb is aborted at init proc. Retry when the model
modification will return TRY_AGAIN or NOT_EXIST.
---
 src/smf/smfd/SmfUpgradeAction.cc | 73 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 65 insertions(+), 8 deletions(-)

diff --git a/src/smf/smfd/SmfUpgradeAction.cc b/src/smf/smfd/SmfUpgradeAction.cc
index d05eea4..4f2696a 100644
--- a/src/smf/smfd/SmfUpgradeAction.cc
+++ b/src/smf/smfd/SmfUpgradeAction.cc
@@ -461,12 +461,12 @@ SaAisErrorT SmfImmCcbAction::execute(SaImmOiHandleT 
i_oiHandle,
                                      const std::string* i_rollbackDn) {
   SaAisErrorT result = SA_AIS_OK;
   SmfRollbackCcb* rollbackCcb = NULL;
+  std::string immRollbackCcbDn;
 
   TRACE_ENTER();
 
   TRACE("Imm ccb actions id %d, size %zu", m_id, m_operations.size());
   if (i_rollbackDn != NULL) {
-    std::string immRollbackCcbDn;
     char idStr[16];
     snprintf(idStr, 16, "%08d", m_id);
     immRollbackCcbDn = "smfRollbackElement=ccb_";
@@ -491,17 +491,74 @@ SaAisErrorT SmfImmCcbAction::execute(SaImmOiHandleT 
i_oiHandle,
   }
 
   if (m_operations.size() > 0) {
-      SmfImmUtils immUtil;
-    if ((result = immUtil.doImmOperations(m_operations, rollbackCcb)) !=
-        SA_AIS_OK) {
-         delete rollbackCcb;
-         rollbackCcb = NULL;
-    }
+    TRACE("Modifying information model");
+    SmfImmUtils immUtil;
+    while (1) {
+      uint32_t retry_count = 0;
+      result = immUtil.doImmOperations(m_operations, rollbackCcb);
+      if (((result == SA_AIS_ERR_TIMEOUT) || (result == SA_AIS_ERR_NOT_EXIST))
+          && (retry_count <= 6)) {
+        int interval = 5;  // seconds
+        // When IMM aborts a CCB because of synch request from a payload, then
+        // the next call of CCBInitialize() will return TRY_AGAIN till the time
+        // the synch is complete.
+        // There is no direct information available to the OM that can indicate
+        // that the CCB or the Adminownerset failed because of an abort and 
also
+        // there is no notification that can indicate that IMM is ready now.
+        // That leaves SMF with the option to correlate error codes returned.
+        //
+        // Notes on treatment of SA_AIS_ERR_TIMEOUT and SA_AIS_ERR_NOT_EXIST
+        // error codes:
+        //
+        // 1) CCB abort when it is not the first 
operation(create/modify/delete)
+        // in the CCB
+        //    and if there is dependency between objects in the CCB:-
+        //
+        // An abort of a CCB and if the objects(Create/Modify/delete) had
+        // some dependency(parent-child) among them, then an API call of
+        // AdminOwnerSet() or the CCBCreate/Delete/Modify() on a dependant
+        // object will return SA_AIS_ERR_NOT_EXIST, because the CCB aborted.
+        //
+        // 2) CCB abort when it is a first operation and/or there is no
+        // intra-ccb objects-dependency:-
+        //
+        // When an ongoing CCB is aborted because of a synch request 
originating
+        // from a payload, then the AdminOwnerSet() or the
+        // CCBCreate/Delete/Modify() will return timeout.
+
+        ++retry_count;
+        LOG_NO("xngthan: SmfUpgradeAction modify IMM failed with error: %s",
+               saf_error(result));
+        LOG_NO("CCB was aborted!?, Retrying: %u", retry_count);
+        // Total retry time of 2.5 minutes for a worst case IMM loaded with say
+        // < 300k objects. Retry every 25 seconds. i.e. (nanosleep for 5
+        // seconds)  + (immutil_ccbInitialize will worstcase wait till 20
+        // seconds).
+        struct timespec sleepTime = {interval, 0};
+        osaf_nanosleep(&sleepTime);
+        // Note: Alternatively Make rollbackCcb unique by adding a method for
+        // this to the rollbackCcb.
+        delete rollbackCcb;
+        rollbackCcb =
+            new (std::nothrow) SmfRollbackCcb(immRollbackCcbDn, i_oiHandle);
+        if (rollbackCcb == NULL) {
+          LOG_ER("SmfImmCcbAction::execute failed to create SmfRollbackCcb");
+          return SA_AIS_ERR_NO_MEMORY;
+        }
+        continue;
+      } else if (result != SA_AIS_OK) {
+        LOG_ER("Giving up, SmfUpgradeAction modify IMM failed, result=%s",
+               saf_error(result));
+        delete rollbackCcb;
+        return result;
+      }
+      break;
+    }/* End while (1) */
   }
 
   if (rollbackCcb != NULL) {
     if ((result = rollbackCcb->execute()) != SA_AIS_OK) {
-      LOG_ER("SmfImmCcbAction::execute failed to store rollback CCB, rc=%s",
+      LOG_ER("SmfImmCcbAction::execute failed to store rollback CCB, 
result=%s",
              saf_error(result));
     }
     delete rollbackCcb;
-- 
2.7.4



_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to