Impala Public Jenkins has submitted this change and it was merged. Change subject: IMPALA-4916: Fix maintenance of set of item sets in DisjointSet. ......................................................................
IMPALA-4916: Fix maintenance of set of item sets in DisjointSet. The bug: The DisjointSet maintains a set of unique item sets using a HashSet<Set<T>>. The problem is that we modified the Set<T> elements after inserting them into the HashSet. This caused the removal of elements from the HashSet to fail. Removal is required for maintaining a consistent DisjointSet. The removal could even fail for the same Set<T> instance because the hashCode() changed from when the Set<T> was originally inserted to when the removal was attempted due to mutation of the Set<T>. An inconsistent DisjointSet can lead to incorrect equivalence classes, which can lead to missing, redundant and even non-executable predicates. Incorrect results and crashes are possible. For most queries, an inconsistent DisjointSet does not alter the equivalence classes, and even fewer queries have incorrect plans. In fact, many of our existing planner tests trigger this bug, but only 3 of them lead to an incorrect value transfer graph, and all 3 had correct plans. The fix: Use an IdentityHashMap to store the set of item sets. It does not rely on the hashCode() and equals() of the stored elements, so the same object can be added and later removed, even when mutated in the meantime. Testing: - Added a Preconditions check in DisjointSet that asserts correct removal of an item set. Many of our existing tests hit the check before this fix. - Added a new unit test for DisjointSet which triggers the bug. - Augmented DisjointSet.checkConsistency() to check for inconsistency in the set of item sets. - Added validation of the value-transfer graph in single-node planner tests. - A private core/hdfs run succeeded. Change-Id: I609c8795c09becd78815605ea8e82e2f99e82212 Reviewed-on: http://gerrit.cloudera.org:8080/5980 Reviewed-by: Alex Behm <[email protected]> Tested-by: Impala Public Jenkins --- M fe/src/main/java/org/apache/impala/analysis/Analyzer.java M fe/src/main/java/org/apache/impala/common/Id.java M fe/src/main/java/org/apache/impala/util/DisjointSet.java M fe/src/test/java/org/apache/impala/planner/PlannerTest.java M fe/src/test/java/org/apache/impala/util/TestDisjointSet.java M testdata/workloads/functional-planner/queries/PlannerTest/joins.test 6 files changed, 65 insertions(+), 19 deletions(-) Approvals: Impala Public Jenkins: Verified Alex Behm: Looks good to me, approved -- To view, visit http://gerrit.cloudera.org:8080/5980 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: merged Gerrit-Change-Id: I609c8795c09becd78815605ea8e82e2f99e82212 Gerrit-PatchSet: 4 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Alex Behm <[email protected]> Gerrit-Reviewer: Alex Behm <[email protected]> Gerrit-Reviewer: Dimitris Tsirogiannis <[email protected]> Gerrit-Reviewer: Impala Public Jenkins Gerrit-Reviewer: Marcel Kornacker <[email protected]>
