You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/08/09 09:56:25 UTC

[GitHub] [kafka] dengziming commented on a diff in pull request #12414: KAFKA-14073 Logging the reason for Snapshot

dengziming commented on code in PR #12414:
URL: https://github.com/apache/kafka/pull/12414#discussion_r941141588


##########
core/src/main/scala/kafka/server/metadata/BrokerMetadataSnapshotter.scala:
##########
@@ -59,11 +60,19 @@ class BrokerMetadataSnapshotter(
       val writer = writerBuilder.build(
         image.highestOffsetAndEpoch().offset,
         image.highestOffsetAndEpoch().epoch,
-        lastContainedLogTime
-      )
+        lastContainedLogTime)
       if (writer.nonEmpty) {
         _currentSnapshotOffset = image.highestOffsetAndEpoch().offset
-        info(s"Creating a new snapshot at offset ${_currentSnapshotOffset}...")
+
+        var stringReasons: Set[String] = Set()
+
+        snapshotReasons.foreach(r => stringReasons += r.toString)
+
+        if (stringReasons.isEmpty){
+          stringReasons += SnapshotReason.UnknownReason.toString
+        }
+
+        info(s"Creating a new snapshot at offset ${_currentSnapshotOffset} because, ${stringReasons.mkString(" and ")}")

Review Comment:
   We directly use snapshotReasons.mkString(" and ") here and remove `stringReasons` and related code.



##########
raft/src/main/java/org/apache/kafka/raft/ReplicatedCounter.java:
##########
@@ -107,6 +107,8 @@ public synchronized void handleCommit(BatchReader<Integer> reader) {
             }
             log.debug("Counter incremented from {} to {}", initialCommitted, committed);
 
+            // A snapshot is being taken here too, not being able to -
+            // `import org.apache.kafka.metadata.utils.SnapshotReason`, figure out why?

Review Comment:
   The `raft` module only relies on the `clients` module so it can't import a class from the `metadata` module.



-- 
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