[ 
https://issues.apache.org/jira/browse/KAFKA-20947?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Westerby reassigned KAFKA-20947:
----------------------------------------

    Assignee: Michael Westerby

> ZkWriteSnapshotTimeMs metric reports negative values
> ----------------------------------------------------
>
>                 Key: KAFKA-20947
>                 URL: https://issues.apache.org/jira/browse/KAFKA-20947
>             Project: Kafka
>          Issue Type: Bug
>          Components: kraft, migration
>    Affects Versions: 3.9.2
>            Reporter: Michael Westerby
>            Assignee: Michael Westerby
>            Priority: Major
>
> The {{ZkWriteSnapshotTimeMs}} metric reports negative values when the KRaft 
> migration driver performs the full metadata sync from KRaft to ZooKeeper 
> during the migration.
> This is due to an error in how the elapsed time is calculated in 
> {{SyncKRaftMetadataEvent}}, where this is computed as {{startTime - endTime}} 
> rather than {{endTime - startTime}}:
> - {code:java}
> controllerMetrics.updateZkWriteSnapshotTimeMs(NANOSECONDS.toMillis(startTime 
> - endTime));
> {code}
> - 
> https://github.com/apache/kafka/blob/5e9866f43ab8e7e41ef39e5584ac50019381328d/metadata/src/main/java/org/apache/kafka/metadata/migration/KRaftMigrationDriver.java#L846
> The correct order is seen in the other call site to this method in 
> {{MetadataChangeEvent}}:
> - {code:java}
> controllerMetrics.updateZkWriteSnapshotTimeMs(NANOSECONDS.toMillis(time.nanoseconds()
>  - startTime));
> {code}
> - 
> https://github.com/apache/kafka/blob/5e9866f43ab8e7e41ef39e5584ac50019381328d/metadata/src/main/java/org/apache/kafka/metadata/migration/KRaftMigrationDriver.java#L572
> The fix for this would be to correct the subtraction order where this is 
> invoked in {{SyncKRaftMetadataEvent}} to prevent these negative values.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to