You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "cmccabe (via GitHub)" <gi...@apache.org> on 2023/04/11 13:49:45 UTC

[GitHub] [kafka] cmccabe opened a new pull request, #13540: MINOR: improve controller logging

cmccabe opened a new pull request, #13540:
URL: https://github.com/apache/kafka/pull/13540

   When creating the QuorumController, log whether ZK migration is enabled.
   
   When applying a feature level record which sets the metadata version, log the metadata version enum rather than the numeric feature level.
   
   Improve the logging when we replay snapshots in QuorumController. Log both the beginning and the end of replay.
   
   When TRACE is enabled, log every record that is replayed in QuorumController. Since some records may contain sensitive information, create RecordRedactor to assist in logging only what is safe to put in the log4j file.
   
   Add logging to ControllerPurgatory. Successful completions are logged at DEBUG; failures are logged at INFO, and additions are logged at TRACE.
   
   Remove SnapshotReason.java, SnapshotReasonTest.java, and QuorumController#generateSnapshotScheduled. They are deadcode now that snapshot generation moved to org.apache.kafka.image.publisher.SnapshotGenerator.


-- 
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: jira-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] jsancio commented on a diff in pull request #13540: MINOR: improve QuorumController logging

Posted by "jsancio (via GitHub)" <gi...@apache.org>.
jsancio commented on code in PR #13540:
URL: https://github.com/apache/kafka/pull/13540#discussion_r1170345743


##########
metadata/src/main/java/org/apache/kafka/controller/ControllerPurgatory.java:
##########
@@ -65,6 +81,7 @@ void failAll(Exception exception) {
         while (iter.hasNext()) {
             Entry<Long, List<DeferredEvent>> entry = iter.next();
             for (DeferredEvent event : entry.getValue()) {
+                log.info("failAll({}): failing {}.", exception.getClass().getSimpleName(), event);

Review Comment:
   I see. We don't log the stacktrace because `failAll` is only called with `NotControllerException`. Should we change the signature of this method to `void failAll(ApiException)`?



##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -977,16 +969,8 @@ public void handleSnapshot(SnapshotReader<ApiMessageAndVersion> reader) {
                         long offset = batch.lastOffset();
                         List<ApiMessageAndVersion> messages = batch.records();
 
-                        if (log.isDebugEnabled()) {
-                            if (log.isTraceEnabled()) {
-                                log.trace("Replaying snapshot ({}) batch with last offset of {}: {}",
-                                    reader.snapshotId(), offset, messages.stream().map(ApiMessageAndVersion::toString).
-                                        collect(Collectors.joining(", ")));
-                            } else {
-                                log.debug("Replaying snapshot ({}) batch with last offset of {}",
-                                    reader.snapshotId(), offset);
-                            }
-                        }
+                        log.debug("Replaying snapshot {} batch with last offset of {}",
+                            reader.snapshotId(), offset);

Review Comment:
   Do you want to use `snapshotName` here to make it consistent with the rest of the log messages?



-- 
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: jira-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] mumrah commented on a diff in pull request #13540: MINOR: improve QuorumController logging

Posted by "mumrah (via GitHub)" <gi...@apache.org>.
mumrah commented on code in PR #13540:
URL: https://github.com/apache/kafka/pull/13540#discussion_r1184415101


##########
metadata/src/main/java/org/apache/kafka/metadata/util/RecordRedactor.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.kafka.metadata.util;
+
+import org.apache.kafka.common.metadata.ConfigRecord;
+import org.apache.kafka.common.metadata.MetadataRecordType;
+import org.apache.kafka.common.metadata.UserScramCredentialRecord;
+import org.apache.kafka.common.protocol.ApiMessage;
+import org.apache.kafka.metadata.KafkaConfigSchema;
+
+
+/**
+ * Converts a metadata record to a string suitable for logging to slf4j.
+ * This means that passwords and key material are omitted from the output.
+ */
+public final class RecordRedactor {

Review Comment:
   Nice. We can make use of this in KRaftMigrationDriver when we log the migrated records (in a separate PR)



-- 
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: jira-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] cmccabe commented on a diff in pull request #13540: MINOR: improve QuorumController logging

Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #13540:
URL: https://github.com/apache/kafka/pull/13540#discussion_r1183132783


##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -977,16 +969,8 @@ public void handleSnapshot(SnapshotReader<ApiMessageAndVersion> reader) {
                         long offset = batch.lastOffset();
                         List<ApiMessageAndVersion> messages = batch.records();
 
-                        if (log.isDebugEnabled()) {
-                            if (log.isTraceEnabled()) {
-                                log.trace("Replaying snapshot ({}) batch with last offset of {}: {}",
-                                    reader.snapshotId(), offset, messages.stream().map(ApiMessageAndVersion::toString).
-                                        collect(Collectors.joining(", ")));
-                            } else {
-                                log.debug("Replaying snapshot ({}) batch with last offset of {}",
-                                    reader.snapshotId(), offset);
-                            }
-                        }
+                        log.debug("Replaying snapshot {} batch with last offset of {}",
+                            reader.snapshotId(), offset);

Review Comment:
   Good idea, done



-- 
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: jira-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] cmccabe commented on a diff in pull request #13540: MINOR: improve QuorumController logging

Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on code in PR #13540:
URL: https://github.com/apache/kafka/pull/13540#discussion_r1183132532


##########
metadata/src/main/java/org/apache/kafka/controller/ControllerPurgatory.java:
##########
@@ -65,6 +81,7 @@ void failAll(Exception exception) {
         while (iter.hasNext()) {
             Entry<Long, List<DeferredEvent>> entry = iter.next();
             for (DeferredEvent event : entry.getValue()) {
+                log.info("failAll({}): failing {}.", exception.getClass().getSimpleName(), event);

Review Comment:
   The rationale for not giving the stacktrace was more brevity, than the fact that it was an `ApiException`. So maybe we can leave the signature as-is?



-- 
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: jira-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] cmccabe commented on pull request #13540: MINOR: improve QuorumController logging

Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe commented on PR #13540:
URL: https://github.com/apache/kafka/pull/13540#issuecomment-1503834445

   The test failure is a flake. I opened https://github.com/apache/kafka/pull/13543/files to fix it.


-- 
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: jira-unsubscribe@kafka.apache.org

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


[GitHub] [kafka] cmccabe closed pull request #13540: MINOR: improve QuorumController logging

Posted by "cmccabe (via GitHub)" <gi...@apache.org>.
cmccabe closed pull request #13540: MINOR: improve QuorumController logging
URL: https://github.com/apache/kafka/pull/13540


-- 
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: jira-unsubscribe@kafka.apache.org

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