andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

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

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