HIVE-11224 : AggregateStatsCache triggers java.util.ConcurrentModificationException under some conditions (Pengcheng Xiong via Thejas Nair)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/90a2cf9e Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/90a2cf9e Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/90a2cf9e Branch: refs/heads/beeline-cli Commit: 90a2cf9e87b22d9f568701dc53c8f8ffbe520fdb Parents: a65bcbd Author: Pengcheng Xiong <pxi...@hortonworks.com> Authored: Tue Jul 14 10:46:30 2015 -0700 Committer: Thejas Nair <the...@hortonworks.com> Committed: Tue Jul 14 10:46:30 2015 -0700 ---------------------------------------------------------------------- .../org/apache/hadoop/hive/metastore/AggregateStatsCache.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/90a2cf9e/metastore/src/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java ---------------------------------------------------------------------- diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java b/metastore/src/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java index 44106f5..65e2c65 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/AggregateStatsCache.java @@ -241,7 +241,8 @@ public class AggregateStatsCache { // We'll count misses as we iterate int maxMisses = (int) maxVariance * numPartsRequested; for (String partName : partNames) { - for (Map.Entry<AggrColStats, MatchStats> entry : candidateMatchStats.entrySet()) { + for (Iterator<Map.Entry<AggrColStats, MatchStats>> iterator = candidateMatchStats.entrySet().iterator(); iterator.hasNext();) { + Map.Entry<AggrColStats, MatchStats> entry = iterator.next(); AggrColStats candidate = entry.getKey(); matchStats = entry.getValue(); if (candidate.getBloomFilter().test(partName.getBytes())) { @@ -252,7 +253,7 @@ public class AggregateStatsCache { // 2nd pass at removing invalid candidates // If misses so far exceed max tolerable misses if (matchStats.misses > maxMisses) { - candidateMatchStats.remove(candidate); + iterator.remove(); continue; } // Check if this is the best match so far