You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2016/10/22 01:40:56 UTC

[1/3] kudu git commit: types: Correct printable name of UNIXTIME_MICROS

Repository: kudu
Updated Branches:
  refs/heads/master 1096d663f -> 4b5425aa3


types: Correct printable name of UNIXTIME_MICROS

UNIXTIME_MICROS is still printing "timestamp" in some errors. This
patch fixes that.

Change-Id: I84b5dc52c3f3ee311330c5151d380b34e13a34ae
Reviewed-on: http://gerrit.cloudera.org:8080/4777
Tested-by: Kudu Jenkins
Reviewed-by: Dinesh Bhat <di...@cloudera.com>
Reviewed-by: Todd Lipcon <to...@apache.org>


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

Branch: refs/heads/master
Commit: 49d0d7f48897adb7bea3031ab7e13ddb80fe7b14
Parents: 1096d66
Author: Jordan Birdsell <jo...@gmail.com>
Authored: Thu Oct 20 18:51:51 2016 -0400
Committer: Todd Lipcon <to...@apache.org>
Committed: Fri Oct 21 17:13:51 2016 +0000

----------------------------------------------------------------------
 src/kudu/common/types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/49d0d7f4/src/kudu/common/types.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/types.h b/src/kudu/common/types.h
index 9bed955..46f0452 100644
--- a/src/kudu/common/types.h
+++ b/src/kudu/common/types.h
@@ -424,7 +424,7 @@ struct DataTypeTraits<UNIXTIME_MICROS> : public DerivedTypeTraits<INT64>{
   static const int US_TO_S = 1000L * 1000L;
 
   static const char* name() {
-    return "timestamp";
+    return "unixtime_micros";
   }
 
   static void AppendDebugStringForValue(const void* val, string* str) {


[3/3] kudu git commit: KUDU-1684 - [python] Add Scan Resource Metrics Capabilities

Posted by ad...@apache.org.
KUDU-1684 - [python] Add Scan Resource Metrics Capabilities

Currently, the python client doesn't expose scanner resource metrics.
This patch enables this ability and includes tests.

Change-Id: Ib6c4057bd2644e46bdbf8bae0d4a768306e2dbd9
Reviewed-on: http://gerrit.cloudera.org:8080/4675
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>


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

Branch: refs/heads/master
Commit: 4b5425aa3cfa70e6ec20e2b67c7976b36ca5d2d9
Parents: 2426ef3
Author: Jordan Birdsell <jo...@gmail.com>
Authored: Sat Oct 8 17:49:43 2016 -0400
Committer: Todd Lipcon <to...@apache.org>
Committed: Fri Oct 21 21:35:35 2016 +0000

----------------------------------------------------------------------
 python/kudu/client.pyx            | 17 +++++++++++++++++
 python/kudu/libkudu_client.pxd    | 10 ++++++++++
 python/kudu/tests/test_scanner.py | 15 +++++++++++++++
 3 files changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/4b5425aa/python/kudu/client.pyx
----------------------------------------------------------------------
diff --git a/python/kudu/client.pyx b/python/kudu/client.pyx
index 261fdbf..ce897a2 100644
--- a/python/kudu/client.pyx
+++ b/python/kudu/client.pyx
@@ -20,6 +20,7 @@
 
 from libcpp.string cimport string
 from libcpp cimport bool as c_bool
+from libcpp.map cimport map
 
 cimport cpython
 from cython.operator cimport dereference as deref
@@ -1453,6 +1454,22 @@ cdef class Scanner:
         result.schema = schema
         return result
 
+    def get_resource_metrics(self):
+        """
+        Return the cumulative resource metrics since the scan was started.
+
+        Returns
+        -------
+        metrics : Dictionary
+        """
+        _map = self.scanner.GetResourceMetrics().Get()
+
+        # Convert map to python dictionary
+        result = {}
+        for it in _map:
+            result[frombytes(it.first)] = it.second
+        return result
+
     def open(self):
         """
         Returns a reference to itself to facilitate chaining

http://git-wip-us.apache.org/repos/asf/kudu/blob/4b5425aa/python/kudu/libkudu_client.pxd
----------------------------------------------------------------------
diff --git a/python/kudu/libkudu_client.pxd b/python/kudu/libkudu_client.pxd
index 9c9899f..83a9b03 100644
--- a/python/kudu/libkudu_client.pxd
+++ b/python/kudu/libkudu_client.pxd
@@ -21,6 +21,7 @@ from libc.stdint cimport *
 from libcpp cimport bool as c_bool
 from libcpp.string cimport string
 from libcpp.vector cimport vector
+from libcpp.map cimport map
 
 # This must be included for cerr and other things to work
 cdef extern from "<iostream>":
@@ -631,6 +632,7 @@ cdef extern from "kudu/client/client.h" namespace "kudu::client" nogil:
         Status AddExclusiveUpperBound(const KuduPartialRow& key)
 
         KuduSchema GetProjectionSchema()
+        const ResourceMetrics& GetResourceMetrics()
         string ToString()
 
     cdef cppclass KuduScanToken:
@@ -681,3 +683,11 @@ cdef extern from "kudu/client/client.h" namespace "kudu::client" nogil:
         KuduWriteOperation* release_failed_op()
 
         c_bool was_possibly_successful()
+
+cdef extern from "kudu/client/resource_metrics.h" namespace "kudu::client" nogil:
+
+    cdef cppclass ResourceMetrics:
+        ResourceMetrics()
+
+        map[string, int64_t] Get()
+        int64_t GetMetric(const string& name)

http://git-wip-us.apache.org/repos/asf/kudu/blob/4b5425aa/python/kudu/tests/test_scanner.py
----------------------------------------------------------------------
diff --git a/python/kudu/tests/test_scanner.py b/python/kudu/tests/test_scanner.py
index 72a22a4..f010f36 100644
--- a/python/kudu/tests/test_scanner.py
+++ b/python/kudu/tests/test_scanner.py
@@ -215,6 +215,21 @@ class TestScanner(TestScanBase):
             # Avoid tight looping
             time.sleep(0.05)
 
+    def test_resource_metrics(self):
+        """
+        Test getting the resource metrics after scanning.
+        """
+
+        # Build scanner and read through all batches and retrieve metrics.
+        scanner = self.table.scanner()
+        scanner.set_fault_tolerant().open()
+        scanner.read_all_tuples()
+        metrics = scanner.get_resource_metrics()
+
+        # Confirm that the scanner returned cache hit and miss values.
+        self.assertTrue('cfile_cache_hit_bytes' in metrics)
+        self.assertTrue('cfile_cache_miss_bytes' in metrics)
+
     def verify_pred_type_scans(self, preds, row_indexes, count_only=False):
         # Using the incoming list of predicates, verify that the row returned
         # matches the inserted tuple at the row indexes specified in a


[2/3] kudu git commit: KUDU-1719: Heap use-after-free and deadlock on Messenger::Init() failure

Posted by ad...@apache.org.
KUDU-1719: Heap use-after-free and deadlock on Messenger::Init() failure

We may end up with a use-after-free or a deadlock depending on a
destruction order race, on a Messenger::Init() failure during a
MessengerBuilder::Build().

The main reason for this is because previously a gscoped_ptr and a
shared_ptr pointed to the same object, causing the destructor to be
called on the same object twice on destruction.

This patch does away with the gscoped_ptr and uses a raw pointer in
MessengerBuilder::Build() instead, where we don't explicitly free the
raw pointer since it will be freed when 'retain_self_' is reset()
anyway.

A more detailed explanation is given in the JIRA.

Change-Id: If48c8481c4bf2255f40ddd38460c1ba40c1b0faa
Reviewed-on: http://gerrit.cloudera.org:8080/4782
Tested-by: Kudu Jenkins
Reviewed-by: Todd Lipcon <to...@apache.org>


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

Branch: refs/heads/master
Commit: 2426ef30650318bafd72cc49984aa7b5719b58e0
Parents: 49d0d7f
Author: Sailesh Mukil <sa...@apache.com>
Authored: Fri Oct 21 11:55:10 2016 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Fri Oct 21 21:22:14 2016 +0000

----------------------------------------------------------------------
 src/kudu/rpc/messenger.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/2426ef30/src/kudu/rpc/messenger.cc
----------------------------------------------------------------------
diff --git a/src/kudu/rpc/messenger.cc b/src/kudu/rpc/messenger.cc
index a543f5d..501191d 100644
--- a/src/kudu/rpc/messenger.cc
+++ b/src/kudu/rpc/messenger.cc
@@ -102,16 +102,17 @@ MessengerBuilder &MessengerBuilder::set_metric_entity(
 
 Status MessengerBuilder::Build(shared_ptr<Messenger> *msgr) {
   RETURN_NOT_OK(SaslInit(kSaslAppName)); // Initialize SASL library before we start making requests
-  gscoped_ptr<Messenger> new_msgr(new Messenger(*this));
+  Messenger* new_msgr(new Messenger(*this));
   Status build_status = new_msgr->Init();
   if (!build_status.ok()) {
+    // 'new_msgr' will be freed when 'retain_self_' is reset, so no need to explicitly free it.
     new_msgr->AllExternalReferencesDropped();
     return build_status;
   }
 
   // See docs on Messenger::retain_self_ for info about this odd hack.
   *msgr = shared_ptr<Messenger>(
-    new_msgr.release(), std::mem_fun(&Messenger::AllExternalReferencesDropped));
+    new_msgr, std::mem_fun(&Messenger::AllExternalReferencesDropped));
   return Status::OK();
 }