kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danburk...@apache.org
Subject kudu git commit: KUDU-2447 Fix TS crashed with "NONE predicate can not be pushed into key"
Date Tue, 17 Jul 2018 21:49:42 GMT
Repository: kudu
Updated Branches:
  refs/heads/branch-1.7.x a307f2a31 -> 2a8893e3e


KUDU-2447 Fix TS crashed with "NONE predicate can not be pushed into key"

tserver crashes on Scan when [lowerPrimaryKey, upperPrimary)
 and predicates of primary column do not overlap

Change-Id: I02810d651e14768f0a85044b0b7f01fa7246c718
Reviewed-on: http://gerrit.cloudera.org:8080/10514
Tested-by: Kudu Jenkins
Reviewed-by: Dan Burkert <danburkert@apache.org>
(cherry picked from commit c7918e87bf1aeb25d5b08f7b340d1ae15806568d)
Reviewed-on: http://gerrit.cloudera.org:8080/10963
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/2a8893e3
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/2a8893e3
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/2a8893e3

Branch: refs/heads/branch-1.7.x
Commit: 2a8893e3e9aed3e36f21bb74baafc93f713b592e
Parents: a307f2a
Author: oclarms <oclarms@gmail.com>
Authored: Fri May 25 19:55:36 2018 +0800
Committer: Dan Burkert <danburkert@apache.org>
Committed: Tue Jul 17 21:49:22 2018 +0000

----------------------------------------------------------------------
 .../kudu/client/TestScannerMultiTablet.java     |  7 +-
 src/kudu/common/scan_spec-test.cc               | 81 ++++++++++++++------
 src/kudu/common/scan_spec.cc                    |  5 +-
 3 files changed, 67 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/2a8893e3/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
index 22a5bed..1d4581f 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestScannerMultiTablet.java
@@ -121,8 +121,13 @@ public class TestScannerMultiTablet extends BaseKuduTest {
   // Test mixing start/end row keys with predicates.
   @Test(timeout = 100000)
   public void testKeysAndPredicates() throws Exception {
+    // Value that doesn't exist, predicates has primary column
+    ColumnRangePredicate predicate = new ColumnRangePredicate(schema.getColumnByIndex(1));
+    predicate.setUpperBound("1");
+    assertEquals(0, countRowsInScan(getScanner("1", "2", "1", "3", predicate)));
+
     // First row from the 2nd tablet.
-    ColumnRangePredicate predicate = new ColumnRangePredicate(schema.getColumnByIndex(2));
+    predicate = new ColumnRangePredicate(schema.getColumnByIndex(2));
     predicate.setLowerBound("1");
     predicate.setUpperBound("1");
     assertEquals(1, countRowsInScan(getScanner("1", "", "2", "", predicate)));

http://git-wip-us.apache.org/repos/asf/kudu/blob/2a8893e3/src/kudu/common/scan_spec-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/scan_spec-test.cc b/src/kudu/common/scan_spec-test.cc
index e24f9d2..d925510 100644
--- a/src/kudu/common/scan_spec-test.cc
+++ b/src/kudu/common/scan_spec-test.cc
@@ -643,34 +643,67 @@ TEST_F(CompositeIntKeysTest, TestLiftPrimaryKeyBounds_BothBounds) {
 // Test that implicit constraints specified in the primary key upper/lower
 // bounds are merged into the set of predicates.
 TEST_F(CompositeIntKeysTest, TestLiftPrimaryKeyBounds_WithPredicates) {
-  // b >= 15
-  // c >= 3
-  // c <= 100
-  // key >= (10, min, min)
-  //      < (10,  90, min)
-  ScanSpec spec;
-  AddPredicate<int8_t>(&spec, "b", GE, 15);
-  AddPredicate<int8_t>(&spec, "c", GE, 3);
-  AddPredicate<int8_t>(&spec, "c", LE, 100);
+  {
+    // b >= 15
+    // c >= 3
+    // c <= 100
+    // key >= (10, min, min)
+    //      < (10,  90, min)
+    ScanSpec spec;
+    AddPredicate<int8_t>(&spec, "b", GE, 15);
+    AddPredicate<int8_t>(&spec, "c", GE, 3);
+    AddPredicate<int8_t>(&spec, "c", LE, 100);
 
-  KuduPartialRow lower_bound(&schema_);
-  CHECK_OK(lower_bound.SetInt8("a", 10));
-  CHECK_OK(lower_bound.SetInt8("b", INT8_MIN));
-  CHECK_OK(lower_bound.SetInt8("c", INT8_MIN));
+    KuduPartialRow lower_bound(&schema_);
+    CHECK_OK(lower_bound.SetInt8("a", 10));
+    CHECK_OK(lower_bound.SetInt8("b", INT8_MIN));
+    CHECK_OK(lower_bound.SetInt8("c", INT8_MIN));
 
-  KuduPartialRow upper_bound(&schema_);
-  CHECK_OK(upper_bound.SetInt8("a", 10));
-  CHECK_OK(upper_bound.SetInt8("b", 90));
-  CHECK_OK(upper_bound.SetInt8("c", INT8_MIN));
+    KuduPartialRow upper_bound(&schema_);
+    CHECK_OK(upper_bound.SetInt8("a", 10));
+    CHECK_OK(upper_bound.SetInt8("b", 90));
+    CHECK_OK(upper_bound.SetInt8("c", INT8_MIN));
 
-  SetLowerBound(&spec, lower_bound);
-  SetExclusiveUpperBound(&spec, upper_bound);
+    SetLowerBound(&spec, lower_bound);
+    SetExclusiveUpperBound(&spec, upper_bound);
 
-  spec.OptimizeScan(schema_, &arena_, &pool_, false);
-  ASSERT_EQ(3, spec.predicates().size());
-  ASSERT_EQ("a = 10", FindOrDie(spec.predicates(), "a").ToString());
-  ASSERT_EQ("b >= 15 AND b < 90", FindOrDie(spec.predicates(), "b").ToString());
-  ASSERT_EQ("c >= 3 AND c < 101", FindOrDie(spec.predicates(), "c").ToString());
+    spec.OptimizeScan(schema_, &arena_, &pool_, false);
+    ASSERT_EQ(3, spec.predicates().size());
+    ASSERT_EQ("a = 10", FindOrDie(spec.predicates(), "a").ToString());
+    ASSERT_EQ("b >= 15 AND b < 90", FindOrDie(spec.predicates(), "b").ToString());
+    ASSERT_EQ("c >= 3 AND c < 101", FindOrDie(spec.predicates(), "c").ToString());
+  }
+  {
+    // b >= 15
+    // c >= 3
+    // c <= 100
+    // key >= (10,  5, min)
+    //      < (10, 10, min)
+    ScanSpec spec;
+    AddPredicate<int8_t>(&spec, "b", GE, 15);
+    AddPredicate<int8_t>(&spec, "c", GE, 3);
+    AddPredicate<int8_t>(&spec, "c", LE, 100);
+
+    KuduPartialRow lower_bound(&schema_);
+    CHECK_OK(lower_bound.SetInt8("a", 10));
+    CHECK_OK(lower_bound.SetInt8("b", 5));
+    CHECK_OK(lower_bound.SetInt8("c", INT8_MIN));
+
+    KuduPartialRow upper_bound(&schema_);
+    CHECK_OK(upper_bound.SetInt8("a", 10));
+    CHECK_OK(upper_bound.SetInt8("b", 10));
+    CHECK_OK(upper_bound.SetInt8("c", INT8_MIN));
+
+    SetLowerBound(&spec, lower_bound);
+    SetExclusiveUpperBound(&spec, upper_bound);
+
+    spec.OptimizeScan(schema_, &arena_, &pool_, false);
+    ASSERT_EQ(3, spec.predicates().size());
+    ASSERT_EQ("a = 10", FindOrDie(spec.predicates(), "a").ToString());
+    ASSERT_EQ("b NONE", FindOrDie(spec.predicates(), "b").ToString());
+    ASSERT_EQ("c >= 3 AND c < 101", FindOrDie(spec.predicates(), "c").ToString());
+    ASSERT_EQ(true, spec.CanShortCircuit());
+  }
 }
 
 // Tests for String parts in composite keys

http://git-wip-us.apache.org/repos/asf/kudu/blob/2a8893e3/src/kudu/common/scan_spec.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/scan_spec.cc b/src/kudu/common/scan_spec.cc
index c232e79..689955d 100644
--- a/src/kudu/common/scan_spec.cc
+++ b/src/kudu/common/scan_spec.cc
@@ -136,7 +136,10 @@ void ScanSpec::OptimizeScan(const Schema& schema,
   // predicates in the optimization step.
   if (!CanShortCircuit()) {
     LiftPrimaryKeyBounds(schema, arena);
-    PushPredicatesIntoPrimaryKeyBounds(schema, arena, pool, remove_pushed_predicates);
+    // Predicates may be has None, after merge PrimaryKeyBounds and Predicates
+    if (!CanShortCircuit()) {
+      PushPredicatesIntoPrimaryKeyBounds(schema, arena, pool, remove_pushed_predicates);
+    }
   }
 
   // KUDU-1652: Filter IS NOT NULL predicates for non-nullable columns.


Mime
View raw message