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 2017/03/18 00:03:19 UTC

[1/2] kudu git commit: [scanner] LOG(INFO) --> VLOG(1) on scanner expiration

Repository: kudu
Updated Branches:
  refs/heads/master 8363b7450 -> 9b52ae148


[scanner] LOG(INFO) --> VLOG(1) on scanner expiration

Made code up-to-date with the TODO comment: replaced LOG(INFO) with
VLOG(1) in the event of scanner expiration.

Change-Id: I78f0b07131aaf4dc4a2cb72bed1ce1647a201b68
Reviewed-on: http://gerrit.cloudera.org:8080/6416
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <ad...@cloudera.com>


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

Branch: refs/heads/master
Commit: 5df142fa35bf04231ee92b622482a1be0b18b294
Parents: 8363b74
Author: Alexey Serbin <as...@cloudera.com>
Authored: Fri Mar 17 14:38:48 2017 -0700
Committer: Adar Dembo <ad...@cloudera.com>
Committed: Sat Mar 18 00:02:44 2017 +0000

----------------------------------------------------------------------
 src/kudu/tserver/scanners.cc | 42 +++++++++++++++++++++++----------------
 src/kudu/tserver/scanners.h  | 12 ++++++-----
 2 files changed, 32 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/5df142fa/src/kudu/tserver/scanners.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/scanners.cc b/src/kudu/tserver/scanners.cc
index e8e79d5..7d9a821 100644
--- a/src/kudu/tserver/scanners.cc
+++ b/src/kudu/tserver/scanners.cc
@@ -16,17 +16,19 @@
 // under the License.
 #include "kudu/tserver/scanners.h"
 
-#include <gflags/gflags.h>
 #include <mutex>
 
+#include <gflags/gflags.h>
+
 #include "kudu/common/iterator.h"
 #include "kudu/common/scan_spec.h"
 #include "kudu/gutil/hash/string_hash.h"
 #include "kudu/gutil/map-util.h"
+#include "kudu/gutil/strings/substitute.h"
 #include "kudu/tserver/scanner_metrics.h"
 #include "kudu/util/flag_tags.h"
-#include "kudu/util/thread.h"
 #include "kudu/util/metrics.h"
+#include "kudu/util/thread.h"
 
 DEFINE_int32(scanner_ttl_ms, 60000,
              "Number of milliseconds of inactivity allowed for a scanner"
@@ -43,6 +45,8 @@ METRIC_DEFINE_gauge_size(server, active_scanners,
                          kudu::MetricUnit::kScanners,
                          "Number of scanners that are currently active");
 
+using strings::Substitute;
+
 namespace kudu {
 
 using tablet::TabletPeer;
@@ -153,31 +157,35 @@ void ScannerManager::ListScanners(std::vector<SharedScanner>* scanners) {
 
 void ScannerManager::RemoveExpiredScanners() {
   MonoDelta scanner_ttl = MonoDelta::FromMilliseconds(FLAGS_scanner_ttl_ms);
+  const MonoTime now = MonoTime::Now();
 
   for (ScannerMapStripe* stripe : scanner_maps_) {
     std::lock_guard<RWMutex> l(stripe->lock_);
     for (auto it = stripe->scanners_by_id_.begin(); it != stripe->scanners_by_id_.end();) {
-      SharedScanner& scanner = it->second;
-      MonoDelta time_live =
-          scanner->TimeSinceLastAccess(MonoTime::Now());
-      if (time_live > scanner_ttl) {
-        // TODO: once we have a metric for the number of scanners expired, make this a
-        // VLOG(1).
-        LOG(INFO) << "Expiring scanner id: " << it->first << ", of tablet " << scanner->tablet_id()
-                  << ", after " << time_live.ToMicroseconds()
-                  << " us of inactivity, which is > TTL ("
-                  << scanner_ttl.ToMicroseconds() << " us).";
-        it = stripe->scanners_by_id_.erase(it);
-        if (metrics_) {
-          metrics_->scanners_expired->Increment();
-        }
-      } else {
+      const SharedScanner& scanner = it->second;
+      MonoDelta idle_time = scanner->TimeSinceLastAccess(now);
+      if (idle_time <= scanner_ttl) {
         ++it;
+        continue;
+      }
+
+      // The scanner has expired because of inactivity.
+      VLOG(1) << Substitute("Expiring scanner id: $0, of tablet $1, "
+                            "after $2 ms of inactivity, which is > TTL ($3 ms).",
+                            it->first,
+                            scanner->tablet_id(),
+                            idle_time.ToMilliseconds(),
+                            scanner_ttl.ToMilliseconds());
+      it = stripe->scanners_by_id_.erase(it);
+      if (metrics_) {
+        metrics_->scanners_expired->Increment();
       }
     }
   }
 }
 
+const std::string Scanner::kNullTabletId = "null tablet";
+
 Scanner::Scanner(string id, const scoped_refptr<TabletPeer>& tablet_peer,
                  string requestor_string, ScannerMetrics* metrics)
     : id_(std::move(id)),

http://git-wip-us.apache.org/repos/asf/kudu/blob/5df142fa/src/kudu/tserver/scanners.h
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/scanners.h b/src/kudu/tserver/scanners.h
index 3e28d69..370d5bc 100644
--- a/src/kudu/tserver/scanners.h
+++ b/src/kudu/tserver/scanners.h
@@ -167,9 +167,9 @@ class ScopedUnregisterScanner {
 // An open scanner on the server side.
 class Scanner {
  public:
-  explicit Scanner(std::string id,
-                   const scoped_refptr<tablet::TabletPeer>& tablet_peer,
-                   std::string requestor_string, ScannerMetrics* metrics);
+  Scanner(std::string id,
+          const scoped_refptr<tablet::TabletPeer>& tablet_peer,
+          std::string requestor_string, ScannerMetrics* metrics);
   ~Scanner();
 
   // Attach an actual iterator and a ScanSpec to this Scanner.
@@ -214,9 +214,9 @@ class Scanner {
   // Return the ScanSpec associated with this Scanner.
   const ScanSpec& spec() const;
 
-  const std::string tablet_id() const {
+  const std::string& tablet_id() const {
     // scanners-test passes a null tablet_peer.
-    return tablet_peer_ ? tablet_peer_->tablet_id() : "null tablet";
+    return tablet_peer_ ? tablet_peer_->tablet_id() : kNullTabletId;
   }
 
   const scoped_refptr<tablet::TabletPeer>& tablet_peer() const { return tablet_peer_; }
@@ -275,6 +275,8 @@ class Scanner {
  private:
   friend class ScannerManager;
 
+  static const std::string kNullTabletId;
+
   // The unique ID of this scanner.
   const std::string id_;
 


[2/2] kudu git commit: Remove TRACE_EVENT from EstimateBytesInPotentiallyAncientUndoDeltas

Posted by ad...@apache.org.
Remove TRACE_EVENT from EstimateBytesInPotentiallyAncientUndoDeltas

This function gets called many thousands of times per maintenance
scheduler op. When enabling tracing, it fills up most of the trace
buffer very quickly, but is rarely interesting.

Change-Id: I2cbbe827c33a4110a7167d4121408f191b89082a
Reviewed-on: http://gerrit.cloudera.org:8080/6415
Reviewed-by: Mike Percy <mp...@apache.org>
Tested-by: Kudu Jenkins
Reviewed-by: David Ribeiro Alves <dr...@apache.org>


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

Branch: refs/heads/master
Commit: 9b52ae1484642b0dce53a93e26aa13a6814ca783
Parents: 5df142f
Author: Todd Lipcon <to...@apache.org>
Authored: Fri Mar 17 11:28:17 2017 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Sat Mar 18 00:03:04 2017 +0000

----------------------------------------------------------------------
 src/kudu/tablet/diskrowset.cc | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/9b52ae14/src/kudu/tablet/diskrowset.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/diskrowset.cc b/src/kudu/tablet/diskrowset.cc
index 014ecee..eb32832 100644
--- a/src/kudu/tablet/diskrowset.cc
+++ b/src/kudu/tablet/diskrowset.cc
@@ -749,7 +749,6 @@ double DiskRowSet::DeltaStoresCompactionPerfImprovementScore(DeltaCompactionType
 
 Status DiskRowSet::EstimateBytesInPotentiallyAncientUndoDeltas(Timestamp ancient_history_mark,
                                                                int64_t* bytes) {
-  TRACE_EVENT0("tablet", "DiskRowSet::EstimateBytesInPotentiallyAncientUndoDeltas");
   return delta_tracker_->EstimateBytesInPotentiallyAncientUndoDeltas(ancient_history_mark, bytes);
 }