You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/12/14 01:06:17 UTC

[GitHub] [hadoop] xkrogen commented on a diff in pull request #5215: HADOOP-18567. LogThrottlingHelper: the dependent recorder is not triggered correctly

xkrogen commented on code in PR #5215:
URL: https://github.com/apache/hadoop/pull/5215#discussion_r1047905288


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/log/LogThrottlingHelper.java:
##########
@@ -262,8 +263,15 @@ public LogAction record(String recorderName, long currentTimeMs,
     if (primaryRecorderName.equals(recorderName) &&
         currentTimeMs - minLogPeriodMs >= lastLogTimestampMs) {
       lastLogTimestampMs = currentTimeMs;
-      for (LoggingAction log : currentLogs.values()) {
-        log.setShouldLog();
+      for (Iterator<LoggingAction> it = currentLogs.values().iterator(); it
+          .hasNext();) {
+        LoggingAction log = it.next();
+        if (log.hasLogged()) {
+          // Make sure the dependent recorders will be triggered the next time
+          it.remove();
+        } else {
+          log.setShouldLog();
+        }
       }

Review Comment:
   This does solve the issue but it feels a bit awkward/confusing to me. Having no entry in `currentLogs` is supposed to indicate that this `recoderName` has never been seen before.
   
   What do you think about this instead:
   ```suggestion
         currentLogs.replaceAll((k, log) -> {
           LoggingAction newLog = log;
           if (log.hasLogged()) {
             // create a fresh log since the old one has already been logged
             newLog = new LoggingAction(log.getValueCount());
           }
           newLog.setShouldLog();
           return newLog;
         });
   ```
   
   I feel it's a bit more explicit/clear about what we're achieving. WDYT?
   
   (note that this also requires creating a new method in `LoggingAction` to expose the value count like `private int getValueCount() { return stats.length; }`)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org