kudu git commit: [logging] fix logging init if linking kudu client library
Repository: kudu Updated Branches: refs/heads/master 825b964fa -> 2ff946030 [logging] fix logging init if linking kudu client library Don't call constructor-like InitializeBasicLogging() function in non-exported builds of the kudu_client library. The rationale is simple: the non-exported kudu_client library is used in Kudu tools, benchmarks, and tests. In tools and benchmarks, InitGoogleLoggingSafe() is called to initialize the logging as needed. In tests, the gtest initializes glog on itself. Prior to this fix, the kudu CLI tool could exit on SIGPIPE when master/tserver abruptly closed connection. That's because the call to InitGoogleLoggingSafe() in the main() function of the CLI tool didn't do anything once InitGoogleLoggingSafeBasic() has been inadvertently called by the linked kudu_client library. Change-Id: I6dcd8d7ccb8a9cafa79674273b95c61eee5baf5a Reviewed-on: http://gerrit.cloudera.org:8080/10956 Tested-by: Kudu Jenkins Reviewed-by: Adar Dembo Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/2ff94603 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/2ff94603 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/2ff94603 Branch: refs/heads/master Commit: 2ff946030113860447931a49cfe69e8469efe5cc Parents: 825b964 Author: Alexey Serbin Authored: Mon Jul 16 15:59:24 2018 -0700 Committer: Alexey Serbin Committed: Tue Jul 17 23:00:07 2018 + -- src/kudu/client/client.cc | 12 src/kudu/tools/tool_main.cc | 21 +++-- 2 files changed, 19 insertions(+), 14 deletions(-) -- http://git-wip-us.apache.org/repos/asf/kudu/blob/2ff94603/src/kudu/client/client.cc -- diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc index 912e71a..b2b4f1b 100644 --- a/src/kudu/client/client.cc +++ b/src/kudu/client/client.cc @@ -152,23 +152,27 @@ class ResourceMetrics; using internal::MetaCache; using sp::shared_ptr; -static const char* kProgName = "kudu_client"; const char* kVerboseEnvVar = "KUDU_CLIENT_VERBOSE"; +#if defined(kudu_client_exported_EXPORTS) +static const char* kProgName = "kudu_client"; + // We need to reroute all logging to stderr when the client library is // loaded. GoogleOnceInit() can do that, but there are multiple entry // points into the client code, and it'd need to be called in each one. // So instead, let's use a constructor function. // -// Should this be restricted to just the exported client build? Probably -// not, as any application using the library probably wants stderr logging -// more than file logging. +// This is restricted to the exported client builds only. In case of linking +// with non-exported kudu client library, logging must be initialized +// from the main() function of the corresponding binary: usually, that's done +// by calling InitGoogleLoggingSafe(argv[0]). __attribute__((constructor)) static void InitializeBasicLogging() { InitGoogleLoggingSafeBasic(kProgName); SetVerboseLevelFromEnvVar(); } +#endif // Set Client logging verbose level from environment variable. void SetVerboseLevelFromEnvVar() { http://git-wip-us.apache.org/repos/asf/kudu/blob/2ff94603/src/kudu/tools/tool_main.cc -- diff --git a/src/kudu/tools/tool_main.cc b/src/kudu/tools/tool_main.cc index f5e0d08..55c5f26 100644 --- a/src/kudu/tools/tool_main.cc +++ b/src/kudu/tools/tool_main.cc @@ -222,19 +222,14 @@ int RunTool(int argc, char** argv, bool show_help) { } // namespace tools } // namespace kudu -static bool ParseCommandLineFlags(int* argc, char*** argv) { - // Hide the regular gflags help unless --helpfull is used. - // - // Inspired by https://github.com/gflags/gflags/issues/43#issuecomment-168280647. - bool show_help = false; - gflags::ParseCommandLineNonHelpFlags(argc, argv, true); - +static bool ParseCommandLineFlags(const char* prog_name) { // Leverage existing helpxml flag to print mode/action xml. if (FLAGS_helpxml) { -kudu::tools::DumpToolXML(*argv[0]); +kudu::tools::DumpToolXML(prog_name); exit(1); } + bool show_help = false; if (FLAGS_help || FLAGS_helpshort || !FLAGS_helpon.empty() || @@ -257,9 +252,15 @@ int main(int argc, char** argv) { CHECK_NE("", google::SetCommandLineOptionWithMode( "redact", "", google::SET_FLAGS_DEFAULT)); + // Hide the regular gflags help unless --helpfull is used. + // + // Inspired by https://github.com/gflags/gflags/issues/43#issuecomment-168280647. + gflags::ParseCommandLineNonHelpFlags(, , true); + FLAGS_logtostderr = true; - bool show_help = ParseCommandLineFlags(, ); + const char* prog_name = argv[0]; + kudu::InitGoogleLoggingSafe(prog_name); + bool show_help
kudu git commit: KUDU-2312: Scan predicate application ordering is non-deterministic
Repository: kudu Updated Branches: refs/heads/branch-1.6.x f0d95c27e -> f43c77bed KUDU-2312: Scan predicate application ordering is non-deterministic This changes the scan predicate evaluation ordering so that it primarily orders by selectivity (as before), but breaks ties by column index. Change-Id: I99b2cabecd8626cad7e11fbdd492af7276e08348 Reviewed-on: http://gerrit.cloudera.org:8080/9440 Tested-by: Kudu Jenkins Reviewed-by: Todd Lipcon Reviewed-on: http://gerrit.cloudera.org:8080/10945 Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/f43c77be Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/f43c77be Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/f43c77be Branch: refs/heads/branch-1.6.x Commit: f43c77bed464556b66bf8f035dc50be541d6cdb4 Parents: f0d95c2 Author: Dan Burkert Authored: Tue Feb 20 11:17:48 2018 -0800 Committer: Dan Burkert Committed: Tue Jul 17 22:10:48 2018 + -- src/kudu/common/generic_iterators-test.cc | 82 +- src/kudu/common/generic_iterators.cc | 34 +++ src/kudu/common/generic_iterators.h | 14 +++-- src/kudu/tablet/cfile_set.h | 1 - 4 files changed, 111 insertions(+), 20 deletions(-) -- http://git-wip-us.apache.org/repos/asf/kudu/blob/f43c77be/src/kudu/common/generic_iterators-test.cc -- diff --git a/src/kudu/common/generic_iterators-test.cc b/src/kudu/common/generic_iterators-test.cc index e7f9250..55eaa09 100644 --- a/src/kudu/common/generic_iterators-test.cc +++ b/src/kudu/common/generic_iterators-test.cc @@ -51,6 +51,7 @@ DEFINE_int32(num_lists, 3, "Number of lists to merge"); DEFINE_int32(num_rows, 1000, "Number of entries per list"); DEFINE_int32(num_iters, 1, "Number of times to run merge"); +using std::make_shared; using std::shared_ptr; using std::string; using std::vector; @@ -309,7 +310,7 @@ TEST(TestPredicateEvaluatingIterator, TestPredicateEvaluation) { ASSERT_EQ(0, spec.predicates().size()) << "Iterator tree should have accepted predicate"; - ASSERT_EQ(1, pred_eval->col_idx_predicates_.size()) + ASSERT_EQ(1, pred_eval->col_predicates_.size()) << "Predicate should be evaluated by the outer iterator"; Arena arena(1024); @@ -338,4 +339,83 @@ TEST(TestPredicateEvaluatingIterator, TestDontWrapWhenNoPredicates) { ASSERT_EQ(outer_iter, materializing) << "InitAndMaybeWrap should not have wrapped iter"; } +// Test row-wise iterator which does nothing. +class DummyIterator : public RowwiseIterator { + public: + + explicit DummyIterator(Schema schema) + : schema_(std::move(schema)) { + } + + Status Init(ScanSpec* /*spec*/) override { +return Status::OK(); + } + + virtual Status NextBlock(RowBlock* /*dst*/) override { +LOG(FATAL) << "unimplemented!"; +return Status::OK(); + } + + virtual bool HasNext() const override { +LOG(FATAL) << "unimplemented!"; +return false; + } + + virtual string ToString() const override { +return "DummyIterator"; + } + + virtual const Schema& schema() const override { +return schema_; + } + + virtual void GetIteratorStats(vector* stats) const override { +stats->resize(schema().num_columns()); + } + + private: + Schema schema_; +}; + +TEST(TestPredicateEvaluatingIterator, TestPredicateEvaluationOrder) { + Schema schema({ ColumnSchema("a_int64", INT64), + ColumnSchema("b_int64", INT64), + ColumnSchema("c_int32", INT32) }, 3); + + int64_t zero = 0; + int64_t two = 2; + auto a_equality = ColumnPredicate::Equality(schema.column(0), ); + auto b_equality = ColumnPredicate::Equality(schema.column(1), ); + auto c_equality = ColumnPredicate::Equality(schema.column(2), ); + auto a_range = ColumnPredicate::Range(schema.column(0), , ); + + { // Test that more selective predicates come before others. +ScanSpec spec; +spec.AddPredicate(a_range); +spec.AddPredicate(b_equality); +spec.AddPredicate(c_equality); + +shared_ptr iter = make_shared(schema); +ASSERT_OK(PredicateEvaluatingIterator::InitAndMaybeWrap(, )); + +PredicateEvaluatingIterator* pred_eval = down_cast(iter.get()); +ASSERT_TRUE(pred_eval->col_predicates_ == +vector({ c_equality, b_equality, a_range })); + } + + { // Test that smaller columns come before larger ones, and ties are broken by idx. +ScanSpec spec; +spec.AddPredicate(b_equality); +spec.AddPredicate(a_equality); +spec.AddPredicate(c_equality); + +shared_ptr iter = make_shared(schema); +ASSERT_OK(PredicateEvaluatingIterator::InitAndMaybeWrap(, )); + +PredicateEvaluatingIterator* pred_eval = down_cast(iter.get()); +ASSERT_TRUE(pred_eval->col_predicates_ == +
kudu git commit: KUDU-2447 Fix TS crashed with "NONE predicate can not be pushed into key"
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 (cherry picked from commit c7918e87bf1aeb25d5b08f7b340d1ae15806568d) Reviewed-on: http://gerrit.cloudera.org:8080/10963 Reviewed-by: Todd Lipcon 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 Authored: Fri May 25 19:55:36 2018 +0800 Committer: Dan Burkert Committed: Tue Jul 17 21:49:22 2018 + -- .../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 = 10) 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(, "b", GE, 15); - AddPredicate(, "c", GE, 3); - AddPredicate(, "c", LE, 100); + { +// b >= 15 +// c >= 3 +// c <= 100 +// key >= (10, min, min) +// < (10, 90, min) +ScanSpec spec; +AddPredicate(, "b", GE, 15); +AddPredicate(, "c", GE, 3); +AddPredicate(, "c", LE, 100); - KuduPartialRow lower_bound(_); - 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(_); +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(_); - 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(_); +CHECK_OK(upper_bound.SetInt8("a", 10)); +CHECK_OK(upper_bound.SetInt8("b", 90)); +CHECK_OK(upper_bound.SetInt8("c", INT8_MIN)); - SetLowerBound(, lower_bound); - SetExclusiveUpperBound(, upper_bound); +SetLowerBound(, lower_bound); +SetExclusiveUpperBound(, upper_bound); - spec.OptimizeScan(schema_, _, _, false); - ASSERT_EQ(3, spec.predicates().size()); - ASSERT_EQ("a = 10", FindOrDie(spec.predicates(),