kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [4/5] kudu git commit: KUDU-1553: Crash when specifying multiple unbounded range predicates on a column
Date Sat, 13 Aug 2016 02:08:49 GMT
KUDU-1553: Crash when specifying multiple unbounded range predicates on a column

The Kudu client and tablet server will crash when a scan specifies multiple
predicates on a column, with at least one of the predicates being a one-sided
range predicate. For instance:

    SELECT * WHERE a > 10 && a = 200;
    SELECT * WHERE a <= 10 &&  a = 5;

will both trigger this crash.

Change-Id: I0f8b21087ba6046f673af9d79b3a60bf8e645cce
Reviewed-on: http://gerrit.cloudera.org:8080/3945
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <todd@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/609054cd
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/609054cd
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/609054cd

Branch: refs/heads/master
Commit: 609054cd8cff886bd9709b7fb652d0c102c7a2e9
Parents: 883785c
Author: bruceSz <zsyuyizhang@gmail.com>
Authored: Thu Aug 11 20:45:14 2016 +0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Fri Aug 12 20:07:20 2016 +0000

----------------------------------------------------------------------
 src/kudu/common/column_predicate-test.cc | 153 ++++++++++++++++++++++++++
 src/kudu/common/column_predicate.cc      |   8 +-
 2 files changed, 157 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/609054cd/src/kudu/common/column_predicate-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/column_predicate-test.cc b/src/kudu/common/column_predicate-test.cc
index 55792d6..77450f0 100644
--- a/src/kudu/common/column_predicate-test.cc
+++ b/src/kudu/common/column_predicate-test.cc
@@ -112,6 +112,69 @@ class TestColumnPredicate : public KuduTest {
               ColumnPredicate::None(column),
               PredicateType::None);
 
+    // [---> AND
+    // [--->
+    // =
+    // [--->
+    TestMerge(ColumnPredicate::Range(column, &values[1], nullptr),
+              ColumnPredicate::Range(column, &values[1], nullptr),
+              ColumnPredicate::Range(column, &values[1], nullptr),
+              PredicateType::Range);
+
+    // [-----> AND
+    //   [--->
+    // =
+    //   [--->
+    TestMerge(ColumnPredicate::Range(column, &values[1], nullptr),
+              ColumnPredicate::Range(column, &values[2], nullptr),
+              ColumnPredicate::Range(column, &values[2], nullptr),
+              PredicateType::Range);
+
+    // <---) AND
+    // <---)
+    // =
+    // <---)
+    TestMerge(ColumnPredicate::Range(column, nullptr, &values[4]),
+              ColumnPredicate::Range(column, nullptr, &values[4]),
+              ColumnPredicate::Range(column, nullptr, &values[4]),
+              PredicateType::Range);
+
+    //   <---) AND
+    // <---)
+    // =
+    // <---)
+    TestMerge(ColumnPredicate::Range(column, nullptr, &values[6]),
+              ColumnPredicate::Range(column, nullptr, &values[4]),
+              ColumnPredicate::Range(column, nullptr, &values[4]),
+              PredicateType::Range);
+
+    // <---) AND
+    // [--->
+    // =
+    // [---)
+    TestMerge(ColumnPredicate::Range(column, nullptr, &values[4]),
+              ColumnPredicate::Range(column, &values[1], nullptr),
+              ColumnPredicate::Range(column, &values[1], &values[4]),
+              PredicateType::Range);
+
+    // <---)     AND
+    //     [--->
+    // =
+    // None
+    TestMerge(ColumnPredicate::Range(column, nullptr, &values[4]),
+              ColumnPredicate::Range(column, &values[4], nullptr),
+              ColumnPredicate::None(column),
+              PredicateType::None);
+
+    // <---)       AND
+    //       [--->
+    // =
+    // None
+    TestMerge(ColumnPredicate::Range(column, nullptr, &values[2]),
+              ColumnPredicate::Range(column, &values[4], nullptr),
+              ColumnPredicate::None(column),
+              PredicateType::None);
+
     // Range + Equality
 
     //   [---) AND
@@ -160,6 +223,60 @@ class TestColumnPredicate : public KuduTest {
               ColumnPredicate::None(column),
               PredicateType::None);
 
+    //   [---> AND
+    // |
+    // =
+    // None
+    TestMerge(ColumnPredicate::Range(column, &values[3], nullptr),
+              ColumnPredicate::Equality(column, &values[1]),
+              ColumnPredicate::None(column),
+              PredicateType::None);
+
+    // [---> AND
+    // |
+    // =
+    // |
+    TestMerge(ColumnPredicate::Range(column, &values[1], nullptr),
+              ColumnPredicate::Equality(column, &values[1]),
+              ColumnPredicate::Equality(column, &values[1]),
+              PredicateType::Equality);
+
+    // [-----> AND
+    //   |
+    // =
+    //   |
+    TestMerge(ColumnPredicate::Range(column, &values[0], nullptr),
+              ColumnPredicate::Equality(column, &values[2]),
+              ColumnPredicate::Equality(column, &values[2]),
+              PredicateType::Equality);
+
+    // <---) AND
+    //   |
+    // =
+    //   |
+    TestMerge(ColumnPredicate::Range(column, nullptr, &values[3]),
+              ColumnPredicate::Equality(column, &values[1]),
+              ColumnPredicate::Equality(column, &values[1]),
+              PredicateType::Equality);
+
+    // <---) AND
+    //     |
+    // =
+    // None
+    TestMerge(ColumnPredicate::Range(column, nullptr, &values[3]),
+              ColumnPredicate::Equality(column, &values[3]),
+              ColumnPredicate::None(column),
+              PredicateType::None);
+
+    // <---)    AND
+    //       |
+    // =
+    // None
+    TestMerge(ColumnPredicate::Range(column, nullptr, &values[1]),
+              ColumnPredicate::Equality(column, &values[3]),
+              ColumnPredicate::None(column),
+              PredicateType::None);
+
     // None
 
     // None AND
@@ -172,6 +289,24 @@ class TestColumnPredicate : public KuduTest {
               PredicateType::None);
 
     // None AND
+    // <----)
+    // =
+    // None
+    TestMerge(ColumnPredicate::None(column),
+              ColumnPredicate::Range(column, nullptr, &values[5]),
+              ColumnPredicate::None(column),
+              PredicateType::None);
+
+    // None AND
+    // [---->
+    // =
+    // None
+    TestMerge(ColumnPredicate::None(column),
+              ColumnPredicate::Range(column, &values[1], nullptr),
+              ColumnPredicate::None(column),
+              PredicateType::None);
+
+    // None AND
     //  |
     // =
     // None
@@ -226,6 +361,24 @@ class TestColumnPredicate : public KuduTest {
               ColumnPredicate::Range(column, &values[0], &values[2]),
               ColumnPredicate::Range(column, &values[0], &values[2]),
               PredicateType::Range);
+
+    // IS NOT NULL AND
+    // <------)
+    // =
+    // <------)
+    TestMerge(ColumnPredicate::IsNotNull(column),
+              ColumnPredicate::Range(column, nullptr, &values[2]),
+              ColumnPredicate::Range(column, nullptr, &values[2]),
+              PredicateType::Range);
+
+    // IS NOT NULL AND
+    // [------>
+    // =
+    // [------>
+    TestMerge(ColumnPredicate::IsNotNull(column),
+              ColumnPredicate::Range(column, &values[2], nullptr),
+              ColumnPredicate::Range(column, &values[2], nullptr),
+              PredicateType::Range);
   }
 };
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/609054cd/src/kudu/common/column_predicate.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/column_predicate.cc b/src/kudu/common/column_predicate.cc
index ea0fe5a..fe3aef4 100644
--- a/src/kudu/common/column_predicate.cc
+++ b/src/kudu/common/column_predicate.cc
@@ -199,8 +199,8 @@ void ColumnPredicate::MergeIntoRange(const ColumnPredicate& other)
{
     };
 
     case PredicateType::Equality: {
-      if (column_.type_info()->Compare(lower_, other.lower_) > 0 ||
-          column_.type_info()->Compare(upper_, other.lower_) <= 0) {
+      if ((lower_ != nullptr && column_.type_info()->Compare(lower_, other.lower_)
> 0) ||
+          (upper_ != nullptr && column_.type_info()->Compare(upper_, other.lower_)
<= 0)) {
         // The equality value does not fall in this range.
         SetToNone();
       } else {
@@ -224,8 +224,8 @@ void ColumnPredicate::MergeIntoEquality(const ColumnPredicate& other)
{
       return;
     }
     case PredicateType::Range: {
-      if (column_.type_info()->Compare(lower_, other.lower_) < 0 ||
-          column_.type_info()->Compare(lower_, other.upper_) >= 0) {
+      if ((other.lower_ != nullptr && column_.type_info()->Compare(lower_, other.lower_)
< 0) ||
+          (other.upper_ != nullptr && column_.type_info()->Compare(lower_, other.upper_)
>= 0)) {
         // This equality value does not fall in the other range.
         SetToNone();
       }


Mime
View raw message