cmccabe commented on code in PR #17502:
URL: https://github.com/apache/kafka/pull/17502#discussion_r1811523833


##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -1855,6 +1633,97 @@ private QuorumController(
         this.raftClient.register(metaLogListener);
     }
 
+    /**
+     * Register the writeNoOpRecord task.
+     *
+     * This task periodically writes a NoOpRecord to the metadata log, if the 
MetadataVersion
+     * supports it.
+     *
+     * @param maxIdleIntervalNs     The period at which to write the 
NoOpRecord.
+     */
+    private void registerWriteNoOpRecord(long maxIdleIntervalNs) {
+        periodicControl.registerTask(new PeriodicTask("writeNoOpRecord",
+            () -> {
+                ArrayList<ApiMessageAndVersion> records = new ArrayList<>(1);
+                if (featureControl.metadataVersion().isNoOpRecordSupported()) {
+                    records.add(new ApiMessageAndVersion(new NoOpRecord(), 
(short) 0));
+                }
+                return ControllerResult.of(records, false);
+            },
+            maxIdleIntervalNs,
+            EnumSet.noneOf(PeriodicTaskFlag.class)));
+    }
+
+    /**
+     * Calculate what the period should be for the maybeFenceStaleBroker task.
+     *
+     * @param sessionTimeoutNs      The configured broker session timeout 
period in nanoseconds.
+     *
+     * @return                      The period for the maybeFenceStaleBroker 
task in nanoseconds.
+     */
+    static long maybeFenceStaleBrokerPeriodNs(long sessionTimeoutNs) {
+        return Math.max(TimeUnit.MILLISECONDS.toNanos(1), sessionTimeoutNs / 
4);

Review Comment:
   The more often we check, the more accurate our timeouts will be. The less 
often we check, the more CPU we save. Using a fourth of the sessionTimeout 
means that we'll have no more than 25% error. In practice this is checking 
every 9.0 / 4 = 2.25 seconds which is not often. I suppose we could bump to 1/8 
 (every 1.125 seconds) to get error down to 12.5%...



-- 
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-unsubscr...@kafka.apache.org

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

Reply via email to