kaisun2000 commented on a change in pull request #365: Fix RoutingTableProvider 
statePropagationLatency metric reporting bug
URL: https://github.com/apache/helix/pull/365#discussion_r308951044
 
 

 ##########
 File path: 
helix-core/src/main/java/org/apache/helix/common/caches/CurrentStateSnapshot.java
 ##########
 @@ -32,18 +37,32 @@ public CurrentStateSnapshot(final Map<PropertyKey, 
CurrentState> currentStateMap
     if (_updatedStateKeys != null && _prevStateMap != null) {
       // Note if the prev state map is empty, this is the first time refresh.
       // So the update is not considered as "recent" change.
+      int driftCnt = 0; // clock drift count for comparing timestamp
       for (PropertyKey propertyKey : _updatedStateKeys) {
         CurrentState prevState = _prevStateMap.get(propertyKey);
         CurrentState curState = _properties.get(propertyKey);
 
         Map<String, Long> partitionUpdateEndTimes = null;
         for (String partition : curState.getPartitionStateMap().keySet()) {
           long newEndTime = curState.getEndTime(partition);
-          if (prevState == null || prevState.getEndTime(partition) < 
newEndTime) {
+          if (prevState == null
+              || prevState.getEndTime(partition) < newEndTime && 
prevState.getEndTime(partition) != -1) {
 
 Review comment:
   The thing is that if preState did not have endTime. The getEndTime will 
return -1. Later when this is used to record propagation latency. The would 
generate exceedingly large time delta, say 1.4T as we saw in the current 
database test. This is to fix this bug.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to