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 Thu, 21 Jun 2018 20:15:45 GMT
Repository: kudu
Updated Branches:
  refs/heads/master 61fb6dc30 -> c7918e87b


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>


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

Branch: refs/heads/master
Commit: c7918e87bf1aeb25d5b08f7b340d1ae15806568d
Parents: 61fb6dc
Author: oclarms <oclarms@gmail.com>
Authored: Fri May 25 19:55:36 2018 +0800
Committer: Dan Burkert <danburkert@apache.org>
Committed: Thu Jun 21 20:15: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/c7918e87/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 7a7fb7e..d4a0c5f 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
@@ -141,8 +141,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/c7918e87/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 8835dc7..79969bd 100644
--- a/src/kudu/common/scan_spec-test.cc
+++ b/src/kudu/common/scan_spec-test.cc
@@ -642,34 +642,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/c7918e87/src/kudu/common/scan_spec.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/scan_spec.cc b/src/kudu/common/scan_spec.cc
index 18dff78..f5caab8 100644
--- a/src/kudu/common/scan_spec.cc
+++ b/src/kudu/common/scan_spec.cc
@@ -142,7 +142,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