浏览代码

Ticket 47304 - reinitialization of a master with a disabled agreement hangs

Bug Description:  When IPA tries to initialize a disabled agreement, the script hangs
                  as the attribute nsds5beginReplicaRefresh is not removed, and always
                  stays in "start" mode.

Fix Description:  Return an error 53, and error text, when trying to initialize a disabled
                  agreement.  Also improved the logging when an agmt or suffix is disabled.

https://fedorahosted.org/389/ticket/47304

Reviewed by: richm(Thanks Rich!)
Mark Reynolds 12 年之前
父节点
当前提交
db6bcd7801
共有 2 个文件被更改,包括 32 次插入19 次删除
  1. 18 10
      ldap/servers/plugins/replication/repl5_agmt.c
  2. 14 9
      ldap/servers/plugins/replication/repl5_agmtlist.c

+ 18 - 10
ldap/servers/plugins/replication/repl5_agmt.c

@@ -2220,16 +2220,24 @@ agmt_set_last_init_status (Repl_Agmt *ra, int ldaprc, int replrc, const char *me
 			}
 			}
 			else if (replrc == NSDS50_REPL_DISABLED)
 			else if (replrc == NSDS50_REPL_DISABLED)
 			{
 			{
-				PR_snprintf(ra->last_init_status, STATUS_LEN, "%d Total update aborted: "
-					"Replication agreement for %s\n can not be updated while the replica is disabled.\n"
-					"(If the suffix is disabled you must enable it then restart the server for replication to take place).",
-					replrc, ra->long_name ? ra->long_name : "a replica");
-				/* Log into the errors log, as "ra->long_name" is not accessible from the caller */
-				slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
-					"Total update aborted: Replication agreement for \"%s\" "
-					"can not be updated while the replica is disabled\n", ra->long_name ? ra->long_name : "a replica");
-				slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
-					"(If the suffix is disabled you must enable it then restart the server for replication to take place).\n");
+				if(agmt_is_enabled(ra)){
+					slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Total update aborted: "
+							"Replication agreement for \"%s\" can not be updated while the suffix is disabled.\n"
+							"You must enable it then restart the server for replication to take place).\n",
+							ra->long_name ? ra->long_name : "a replica");
+					PR_snprintf(ra->last_init_status, STATUS_LEN, "%d Total update aborted: "
+							"Replication agreement for \"%s\" can not be updated while the suffix is disabled.\n"
+							"You must enable it then restart the server for replication to take place).",
+							replrc, ra->long_name ? ra->long_name : "a replica");
+				} else {
+					/* You do not need to restart the server after enabling the agreement */
+					slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "Total update aborted: "
+							"Replication agreement for \"%s\" can not be updated while the agreement is disabled\n",
+							ra->long_name ? ra->long_name : "a replica");
+					PR_snprintf(ra->last_init_status, STATUS_LEN, "%d Total update aborted: "
+							"Replication agreement for \"%s\" can not be updated while the agreement is disabled.",
+							replrc, ra->long_name ? ra->long_name : "a replica");
+				}
 			}
 			}
 			else
 			else
 			{
 			{

+ 14 - 9
ldap/servers/plugins/replication/repl5_agmtlist.c

@@ -302,10 +302,8 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
                 {
                 {
                     PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE, "Invalid value (%s) value supplied for attr (%s)", 
                     PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE, "Invalid value (%s) value supplied for attr (%s)", 
                              val, mods[i]->mod_type);
                              val, mods[i]->mod_type);
-                    slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: %s\n",
-                                    errortext);	
+                    slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "agmtlist_modify_callback: %s\n", errortext);
                 }
                 }
-            
                 slapi_ch_free ((void**)&val);
                 slapi_ch_free ((void**)&val);
             }
             }
 		}
 		}
@@ -529,15 +527,22 @@ agmtlist_modify_callback(Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry
     }
     }
     else if (start_initialize)
     else if (start_initialize)
     {
     {
-	if (agmt_initialize_replica(agmt) != 0) {
-		/* The suffix is disabled */
-		agmt_set_last_init_status(agmt, 0, NSDS50_REPL_DISABLED, NULL);
-	}
+        if (agmt_initialize_replica(agmt) != 0) {
+            /* The suffix/repl agmt is disabled */
+            agmt_set_last_init_status(agmt, 0, NSDS50_REPL_DISABLED, NULL);
+            if(agmt_is_enabled(agmt)){
+                PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "Suffix is disabled");
+            } else {
+                PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "Replication agreement is disabled");
+            }
+            *returncode = LDAP_UNWILLING_TO_PERFORM;
+            rc = SLAPI_DSE_CALLBACK_ERROR;
+        }
     }
     }
     else if (cancel_initialize)
     else if (cancel_initialize)
     {
     {
-		agmt_replica_init_done(agmt);
-	}
+        agmt_replica_init_done(agmt);
+    }
 
 
 	if (update_the_schedule) 
 	if (update_the_schedule) 
     {
     {