Blame SOURCES/0079-Ticket-49439-cleanallruv-is-not-logging-information.patch

61f723
From 8031684255007b42df3d08b80e674aefb0ebfb2d Mon Sep 17 00:00:00 2001
61f723
From: Mark Reynolds <mreynolds@redhat.com>
61f723
Date: Thu, 2 Nov 2017 12:55:11 -0400
61f723
Subject: [PATCH] Ticket 49439 - cleanallruv is not logging information
61f723
61f723
Bug Description:  During the logging refector effro from ticket 48978
61f723
                  a mistake was made and cleanruv_log() was using
61f723
                  LOG_NOTICE (which is not a true log level), it was
61f723
                  supposed to be SLAPI_LOG_NOTICE.
61f723
61f723
                  We also use DEBUG defines to contorl the logging for
61f723
                  debug builds
61f723
61f723
Fix Description:  Remove the LDAP_DEBUG defines in cleanruv_log, and set
61f723
                  the correct logging severity level.
61f723
61f723
https://pagure.io/389-ds-base/issue/49439
61f723
61f723
Reviewed by: firstyear(Thanks!)
61f723
61f723
(cherry picked from commit e1f866a5e3ccce8e061e361c0e3dd11175a8acf2)
61f723
---
61f723
 .../plugins/replication/repl5_replica_config.c     | 101 +++++++++++----------
61f723
 1 file changed, 51 insertions(+), 50 deletions(-)
61f723
61f723
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
61f723
index 053103bd0..814f1cac0 100644
61f723
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
61f723
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
61f723
@@ -1911,12 +1911,13 @@ replica_cleanallruv_thread(void *arg)
61f723
         /*
61f723
          *  need to sleep between passes
61f723
          */
61f723
-        cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, LOG_NOTICE, "Not all replicas have received the "
61f723
-            "cleanallruv extended op, retrying in %d seconds",interval);
61f723
-        if(!slapi_is_shutting_down()){
61f723
-            PR_Lock( notify_lock );
61f723
-            PR_WaitCondVar( notify_cvar, PR_SecondsToInterval(interval) );
61f723
-            PR_Unlock( notify_lock );
61f723
+        cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE, "Not all replicas have received the "
61f723
+                     "cleanallruv extended op, retrying in %d seconds",
61f723
+                     interval);
61f723
+        if (!slapi_is_shutting_down()) {
61f723
+            PR_Lock(notify_lock);
61f723
+            PR_WaitCondVar(notify_cvar, PR_SecondsToInterval(interval));
61f723
+            PR_Unlock(notify_lock);
61f723
         }
61f723
         if(interval < 14400){ /* 4 hour max */
61f723
             interval = interval * 2;
61f723
@@ -1952,8 +1953,8 @@ replica_cleanallruv_thread(void *arg)
61f723
                 found_dirty_rid = 0;
61f723
             } else {
61f723
                 found_dirty_rid = 1;
61f723
-                cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, LOG_NOTICE, "Replica is not cleaned yet (%s)",
61f723
-                        agmt_get_long_name(agmt));
61f723
+                cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE, "Replica is not cleaned yet (%s)",
61f723
+                             agmt_get_long_name(agmt));
61f723
                 break;
61f723
             }
61f723
             agmt_obj = agmtlist_get_next_agreement_for_replica (data->replica, agmt_obj);
61f723
@@ -1969,12 +1970,13 @@ replica_cleanallruv_thread(void *arg)
61f723
         /*
61f723
          * Need to sleep between passes unless we are shutting down
61f723
          */
61f723
-        if (!slapi_is_shutting_down()){
61f723
-            cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, LOG_NOTICE, "Replicas have not been cleaned yet, "
61f723
-                "retrying in %d seconds", interval);
61f723
-            PR_Lock( notify_lock );
61f723
-            PR_WaitCondVar( notify_cvar, PR_SecondsToInterval(interval) );
61f723
-            PR_Unlock( notify_lock );
61f723
+        if (!slapi_is_shutting_down()) {
61f723
+            cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE, "Replicas have not been cleaned yet, "
61f723
+                                                                            "retrying in %d seconds",
61f723
+                         interval);
61f723
+            PR_Lock(notify_lock);
61f723
+            PR_WaitCondVar(notify_cvar, PR_SecondsToInterval(interval));
61f723
+            PR_Unlock(notify_lock);
61f723
         }
61f723
 
61f723
         if(interval < 14400){ /* 4 hour max */
61f723
@@ -2008,11 +2010,11 @@ done:
61f723
         /*
61f723
          *  Shutdown or abort
61f723
          */
61f723
-        if(!is_task_aborted(data->rid) || slapi_is_shutting_down()){
61f723
-            cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, LOG_NOTICE,
61f723
-                    "Server shutting down.  Process will resume at server startup");
61f723
+        if (!is_task_aborted(data->rid) || slapi_is_shutting_down()) {
61f723
+            cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE,
61f723
+                         "Server shutting down.  Process will resume at server startup");
61f723
         } else {
61f723
-            cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, LOG_NOTICE, "Task aborted for rid(%d).",data->rid);
61f723
+            cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE, "Task aborted for rid(%d).", data->rid);
61f723
             delete_cleaned_rid_config(data);
61f723
             remove_cleaned_rid(data->rid);
61f723
         }
61f723
@@ -2180,7 +2182,7 @@ check_replicas_are_done_cleaning(cleanruv_data *data )
61f723
             break;
61f723
         }
61f723
 
61f723
-        cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, LOG_NOTICE,
61f723
+        cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE,
61f723
                      "Not all replicas finished cleaning, retrying in %d seconds",
61f723
                      interval);
61f723
         if(!slapi_is_shutting_down()){
61f723
@@ -2289,12 +2291,12 @@ check_replicas_are_done_aborting(cleanruv_data *data )
61f723
         if(not_all_aborted == 0){
61f723
             break;
61f723
         }
61f723
-        cleanruv_log(data->task, data->rid, ABORT_CLEANALLRUV_ID, LOG_NOTICE,
61f723
-                "Not all replicas finished aborting, retrying in %d seconds",interval);
61f723
-        if(!slapi_is_shutting_down()){
61f723
-            PR_Lock( notify_lock );
61f723
-            PR_WaitCondVar( notify_cvar, PR_SecondsToInterval(interval) );
61f723
-            PR_Unlock( notify_lock );
61f723
+        cleanruv_log(data->task, data->rid, ABORT_CLEANALLRUV_ID, SLAPI_LOG_NOTICE,
61f723
+                     "Not all replicas finished aborting, retrying in %d seconds", interval);
61f723
+        if (!slapi_is_shutting_down()) {
61f723
+            PR_Lock(notify_lock);
61f723
+            PR_WaitCondVar(notify_cvar, PR_SecondsToInterval(interval));
61f723
+            PR_Unlock(notify_lock);
61f723
         }
61f723
         if(interval < 14400){ /* 4 hour max */
61f723
             interval = interval * 2;
61f723
@@ -2336,8 +2338,8 @@ check_agmts_are_caught_up(cleanruv_data *data, char *maxcsn)
61f723
                 not_all_caughtup = 0;
61f723
             } else {
61f723
                 not_all_caughtup = 1;
61f723
-                cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, LOG_NOTICE,
61f723
-                        "Replica not caught up (%s)",agmt_get_long_name(agmt));
61f723
+                cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE,
61f723
+                             "Replica not caught up (%s)", agmt_get_long_name(agmt));
61f723
                 break;
61f723
             }
61f723
             agmt_obj = agmtlist_get_next_agreement_for_replica (data->replica, agmt_obj);
61f723
@@ -2346,12 +2348,12 @@ check_agmts_are_caught_up(cleanruv_data *data, char *maxcsn)
61f723
         if(not_all_caughtup == 0 || is_task_aborted(data->rid) ){
61f723
             break;
61f723
         }
61f723
-        cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, LOG_NOTICE,
61f723
-                "Not all replicas caught up, retrying in %d seconds",interval);
61f723
-        if(!slapi_is_shutting_down()){
61f723
-            PR_Lock( notify_lock );
61f723
-            PR_WaitCondVar( notify_cvar, PR_SecondsToInterval(interval) );
61f723
-            PR_Unlock( notify_lock );
61f723
+        cleanruv_log(data->task, data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE,
61f723
+                     "Not all replicas caught up, retrying in %d seconds", interval);
61f723
+        if (!slapi_is_shutting_down()) {
61f723
+            PR_Lock(notify_lock);
61f723
+            PR_WaitCondVar(notify_cvar, PR_SecondsToInterval(interval));
61f723
+            PR_Unlock(notify_lock);
61f723
         }
61f723
         if(interval < 14400){ /* 4 hour max */
61f723
             interval = interval * 2;
61f723
@@ -2396,8 +2398,8 @@ check_agmts_are_alive(Replica *replica, ReplicaId rid, Slapi_Task *task)
61f723
                 not_all_alive = 0;
61f723
             } else {
61f723
                 not_all_alive = 1;
61f723
-                cleanruv_log(task, rid, CLEANALLRUV_ID, LOG_NOTICE, "Replica not online (%s)",
61f723
-                        agmt_get_long_name(agmt));
61f723
+                cleanruv_log(task, rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE, "Replica not online (%s)",
61f723
+                             agmt_get_long_name(agmt));
61f723
                 break;
61f723
             }
61f723
             agmt_obj = agmtlist_get_next_agreement_for_replica (replica, agmt_obj);
61f723
@@ -2406,8 +2408,8 @@ check_agmts_are_alive(Replica *replica, ReplicaId rid, Slapi_Task *task)
61f723
         if(not_all_alive == 0 || is_task_aborted(rid)){
61f723
             break;
61f723
         }
61f723
-        cleanruv_log(task, rid, CLEANALLRUV_ID, LOG_NOTICE, "Not all replicas online, retrying in %d seconds...",
61f723
-                interval);
61f723
+        cleanruv_log(task, rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE, "Not all replicas online, retrying in %d seconds...",
61f723
+                     interval);
61f723
 
61f723
         if(!slapi_is_shutting_down()){
61f723
             PR_Lock( notify_lock );
61f723
@@ -3174,11 +3176,11 @@ replica_abort_task_thread(void *arg)
61f723
         /*
61f723
          *  Need to sleep between passes. unless we are shutting down
61f723
          */
61f723
-        if (!slapi_is_shutting_down()){
61f723
-            cleanruv_log(data->task, data->rid, ABORT_CLEANALLRUV_ID, LOG_NOTICE, "Retrying in %d seconds",interval);
61f723
-            PR_Lock( notify_lock );
61f723
-            PR_WaitCondVar( notify_cvar, PR_SecondsToInterval(interval) );
61f723
-            PR_Unlock( notify_lock );
61f723
+        if (!slapi_is_shutting_down()) {
61f723
+            cleanruv_log(data->task, data->rid, ABORT_CLEANALLRUV_ID, SLAPI_LOG_NOTICE, "Retrying in %d seconds", interval);
61f723
+            PR_Lock(notify_lock);
61f723
+            PR_WaitCondVar(notify_cvar, PR_SecondsToInterval(interval));
61f723
+            PR_Unlock(notify_lock);
61f723
         }
61f723
 
61f723
         if(interval < 14400){ /* 4 hour max */
61f723
@@ -3296,9 +3298,10 @@ replica_cleanallruv_send_extop(Repl_Agmt *ra, cleanruv_data *clean_data, int che
61f723
                     /* extop was accepted */
61f723
                     rc = 0;
61f723
                 } else {
61f723
-                    cleanruv_log(clean_data->task, clean_data->rid, CLEANALLRUV_ID, LOG_NOTICE, 
61f723
-                            "Replica %s does not support the CLEANALLRUV task.  "
61f723
-                            "Sending replica CLEANRUV task...", slapi_sdn_get_dn(agmt_get_dn_byref(ra)));
61f723
+                    cleanruv_log(clean_data->task, clean_data->rid, CLEANALLRUV_ID, SLAPI_LOG_NOTICE,
61f723
+                                 "Replica %s does not support the CLEANALLRUV task.  "
61f723
+                                 "Sending replica CLEANRUV task...",
61f723
+                                 slapi_sdn_get_dn(agmt_get_dn_byref(ra)));
61f723
                     /*
61f723
                      *  Ok, this replica doesn't know about CLEANALLRUV, so just manually
61f723
                      *  add the CLEANRUV task to the replica.
61f723
@@ -3463,9 +3466,9 @@ replica_cleanallruv_check_maxcsn(Repl_Agmt *agmt, char *basedn, char *rid_text,
61f723
                     csn_init_by_string(repl_max, remote_maxcsn);
61f723
                     if(csn_compare (repl_max, max) < 0){
61f723
                         /* we are not caught up yet, free, and return */
61f723
-                        cleanruv_log(task, atoi(rid_text), CLEANALLRUV_ID, LOG_NOTICE,
61f723
-                            "Replica maxcsn (%s) is not caught up with deleted replica's maxcsn(%s)",
61f723
-                            remote_maxcsn, maxcsn);
61f723
+                        cleanruv_log(task, atoi(rid_text), CLEANALLRUV_ID, SLAPI_LOG_NOTICE,
61f723
+                                     "Replica maxcsn (%s) is not caught up with deleted replica's maxcsn(%s)",
61f723
+                                     remote_maxcsn, maxcsn);
61f723
                         rc = -1;
61f723
                     } else {
61f723
                         /* ok this replica is caught up */
61f723
@@ -3636,7 +3639,6 @@ stop_ruv_cleaning()
61f723
 void
61f723
 cleanruv_log(Slapi_Task *task, int rid, char *task_type, int sev_level, char *fmt, ...)
61f723
 {
61f723
-#ifdef LDAP_DEBUG
61f723
     va_list ap1;
61f723
     va_list ap2;
61f723
     va_list ap3;
61f723
@@ -3661,7 +3663,6 @@ cleanruv_log(Slapi_Task *task, int rid, char *task_type, int sev_level, char *fm
61f723
     va_end(ap2);
61f723
     va_end(ap3);
61f723
     va_end(ap4);
61f723
-#endif
61f723
 }
61f723
 
61f723
 char *
61f723
-- 
61f723
2.13.6
61f723