Fix for transient error failure -- concurrent evictions causing incorrectness
authorrmatharu@linkedin.com <rmatharu@linkedin.com>
Wed, 8 Aug 2018 00:39:04 +0000 (17:39 -0700)
committerJagadish <jvenkatraman@linkedin.com>
Wed, 8 Aug 2018 00:39:04 +0000 (17:39 -0700)
Author: rmatharu@linkedin.com <rmatharu@linkedin.com>

Reviewers: Jagadish <jagadish@apache.org>

Closes #599 from rmatharu/bugfix

samza-api/src/main/java/org/apache/samza/metrics/ListGauge.java

index 545fd45..d0fb326 100644 (file)
@@ -109,8 +109,9 @@ public class ListGauge<T> implements Metric {
 
   /**
    * Evicts entries from the elements list, based on the given item-size and durationThreshold.
+   * Concurrent eviction threads can cause incorrectness (when reading elements.size or elements.peek).
    */
-  private void evict() {
+  private synchronized void evict() {
     this.evictBasedOnSize();
     this.evictBasedOnTimestamp();
   }