You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2016/09/13 07:14:15 UTC

[1/3] kudu git commit: Revert "java: fix leak of TabletClient objects in client2tablets map"

Repository: kudu
Updated Branches:
  refs/heads/branch-1.0.x e4213d590 -> 6f6e49ca9


Revert "java: fix leak of TabletClient objects in client2tablets map"

This reverts commit d5082d8ec1218e3f3bd2143d117ddd64772a6162. It was
fonud to be unstable on master, so reverting for branch-1.0.

Change-Id: I2e9e227af0acfb677572a8baad9692ce08c46be0
Reviewed-on: http://gerrit.cloudera.org:8080/4398
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/9504d5e3
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/9504d5e3
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/9504d5e3

Branch: refs/heads/branch-1.0.x
Commit: 9504d5e312aee05c6214c916fd8d36760af1873c
Parents: e4213d5
Author: Todd Lipcon <to...@apache.org>
Authored: Mon Sep 12 20:27:37 2016 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Sep 13 04:18:29 2016 +0000

----------------------------------------------------------------------
 .../org/apache/kudu/client/AsyncKuduClient.java | 28 +------------
 .../org/apache/kudu/client/BaseKuduTest.java    |  2 +-
 .../org/apache/kudu/client/MiniKuduCluster.java |  4 +-
 .../kudu/client/TestAsyncKuduSession.java       | 43 --------------------
 4 files changed, 5 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/9504d5e3/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
index a4da389..c42bd2f 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
@@ -167,8 +167,7 @@ public class AsyncKuduClient implements AutoCloseable {
    * Maps a client connected to a TabletServer to the list of tablets we know
    * it's serving so far.
    */
-  @VisibleForTesting
-  final ConcurrentHashMap<TabletClient, ArrayList<RemoteTablet>> client2tablets =
+  private final ConcurrentHashMap<TabletClient, ArrayList<RemoteTablet>> client2tablets =
       new ConcurrentHashMap<>();
 
   /**
@@ -1529,8 +1528,7 @@ public class AsyncKuduClient implements AutoCloseable {
       final TabletClientPipeline pipeline = new TabletClientPipeline();
       client = pipeline.init(uuid, host, port);
       chan = channelFactory.newChannel(pipeline);
-      TabletClient oldClient = ip2client.put(hostport, client);
-      assert oldClient == null;
+      ip2client.put(hostport, client);  // This is guaranteed to return null.
 
       // The client2tables map is assumed to contain `client` after it is published in ip2client.
       this.client2tablets.put(client, new ArrayList<RemoteTablet>());
@@ -1787,29 +1785,7 @@ public class AsyncKuduClient implements AutoCloseable {
       LOG.trace("When expiring " + client + " from the client cache (host:port="
           + hostport + "), it was found that there was no entry"
           + " corresponding to " + remote + ".  This shouldn't happen.");
-    } else {
-      removeClient(old);
-    }
-  }
-
-  /**
-   * Remove all references to a client from client2tablets and from the remoteTablets
-   * that reference it.
-   * @param client tablet client to remove
-   */
-  void removeClient(final TabletClient client) {
-    ArrayList<RemoteTablet> tablets = client2tablets.get(client);
-    if (tablets != null) {
-      // Make a copy so we don't need to synchronize on it while iterating.
-      RemoteTablet[] tablets_copy;
-      synchronized (tablets) {
-        tablets_copy = tablets.toArray(new RemoteTablet[tablets.size()]);
-      }
-      for (final RemoteTablet remoteTablet : tablets_copy) {
-        remoteTablet.removeTabletClient(client);
-      }
     }
-    client2tablets.remove(client);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/kudu/blob/9504d5e3/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
index 41015a4..967c735 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/BaseKuduTest.java
@@ -42,7 +42,7 @@ import static org.junit.Assert.fail;
 
 public class BaseKuduTest {
 
-  protected static final Logger LOG = LoggerFactory.getLogger(BaseKuduTest.class);
+  private static final Logger LOG = LoggerFactory.getLogger(BaseKuduTest.class);
 
   private static final String NUM_MASTERS_PROP = "NUM_MASTERS";
   private static final int NUM_TABLET_SERVERS = 3;

http://git-wip-us.apache.org/repos/asf/kudu/blob/9504d5e3/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
index 386ce9e..34e44bf 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/MiniKuduCluster.java
@@ -311,11 +311,11 @@ public class MiniKuduCluster implements AutoCloseable {
   }
 
   /**
-   * Restarts any tablet servers which were previously killed.
+   * Restarts the dead tablet servers on the port.
+   * @throws Exception
    */
   public void restartDeadTabletServers() throws Exception {
     for (int port : tserverPorts) {
-      if (tserverProcesses.containsKey(port)) continue;
       restartDeadTabletServerOnPort(port);
     }
   }

http://git-wip-us.apache.org/repos/asf/kudu/blob/9504d5e3/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java
index 15ce59b..cf14b7c 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestAsyncKuduSession.java
@@ -172,49 +172,6 @@ public class TestAsyncKuduSession extends BaseKuduTest {
     }
   }
 
-  /**
-   * Regression test for a bug in which, when a tablet client is disconnected
-   * and we reconnect, we were previously leaking the old TabletClient
-   * object in the client2tablets map.
-   */
-  @Test(timeout = 100000)
-  public void testRestartBetweenWrites() throws Exception {
-    // Create a non-replicated table for this test, so that
-    // we're sure when we reconnect to the leader after restarting
-    // the tablet servers, it's definitely the same leader we wrote
-    // to before.
-    KuduTable nonReplicatedTable = createTable(
-        "non-replicated",
-        basicSchema,
-        getBasicCreateTableOptions().setNumReplicas(1));
-
-    try {
-      // Write before doing any restarts to establish a connection.
-      AsyncKuduSession session = client.newSession();
-      session.setTimeoutMillis(30000);
-      session.setFlushMode(SessionConfiguration.FlushMode.AUTO_FLUSH_SYNC);
-      session.apply(createBasicSchemaInsert(nonReplicatedTable, 1)).join();
-
-      int numClientsBefore = client.client2tablets.size();
-
-      // Restart all the tablet servers.
-      killTabletServers();
-      restartTabletServers();
-
-      // Perform another write, which will require reconnecting to the same
-      // tablet server that we wrote to above.
-      session.apply(createBasicSchemaInsert(nonReplicatedTable, 2)).join();
-
-      // We should not have leaked an entry in the client2tablets map.
-      int numClientsAfter = client.client2tablets.size();
-      assertEquals(numClientsBefore, numClientsAfter);
-    } finally {
-      restartTabletServers();
-
-      client.deleteTable("non-replicated").join();
-    }
-  }
-
   @Test(timeout = 100000)
   public void test() throws Exception {
 


[2/3] kudu git commit: Change version to non-SNAPSHOT in branch

Posted by to...@apache.org.
Change version to non-SNAPSHOT in branch

Change-Id: Ibc73006692673591a78c1bf3a101058ad62fc014
Reviewed-on: http://gerrit.cloudera.org:8080/4399
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/b866f401
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/b866f401
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/b866f401

Branch: refs/heads/branch-1.0.x
Commit: b866f40184b9198a3d4d2fd7c3f78bf728e9ff19
Parents: 9504d5e
Author: Todd Lipcon <to...@apache.org>
Authored: Mon Sep 12 20:27:23 2016 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Sep 13 04:18:49 2016 +0000

----------------------------------------------------------------------
 java/interface-annotations/pom.xml       | 2 +-
 java/kudu-client-tools/pom.xml           | 2 +-
 java/kudu-client/pom.xml                 | 2 +-
 java/kudu-csd/pom.xml                    | 4 ++--
 java/kudu-csd/src/descriptor/service.sdl | 2 +-
 java/kudu-flume-sink/pom.xml             | 2 +-
 java/kudu-mapreduce/pom.xml              | 2 +-
 java/kudu-spark/pom.xml                  | 2 +-
 java/pom.xml                             | 2 +-
 version.txt                              | 2 +-
 10 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/interface-annotations/pom.xml
----------------------------------------------------------------------
diff --git a/java/interface-annotations/pom.xml b/java/interface-annotations/pom.xml
index f1455fd..d80ac27 100644
--- a/java/interface-annotations/pom.xml
+++ b/java/interface-annotations/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <groupId>org.apache.kudu</groupId>
     <artifactId>kudu-parent</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
   </parent>
 
   <artifactId>interface-annotations</artifactId>

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/kudu-client-tools/pom.xml
----------------------------------------------------------------------
diff --git a/java/kudu-client-tools/pom.xml b/java/kudu-client-tools/pom.xml
index 775787b..0c60e47 100644
--- a/java/kudu-client-tools/pom.xml
+++ b/java/kudu-client-tools/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.kudu</groupId>
         <artifactId>kudu-parent</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0</version>
     </parent>
 
     <artifactId>kudu-client-tools</artifactId>

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/kudu-client/pom.xml
----------------------------------------------------------------------
diff --git a/java/kudu-client/pom.xml b/java/kudu-client/pom.xml
index 6f2f03e..15efe9b 100644
--- a/java/kudu-client/pom.xml
+++ b/java/kudu-client/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.kudu</groupId>
         <artifactId>kudu-parent</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0</version>
     </parent>
 
     <artifactId>kudu-client</artifactId>

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/kudu-csd/pom.xml
----------------------------------------------------------------------
diff --git a/java/kudu-csd/pom.xml b/java/kudu-csd/pom.xml
index e846655..284dbb4 100644
--- a/java/kudu-csd/pom.xml
+++ b/java/kudu-csd/pom.xml
@@ -19,12 +19,12 @@ limitations under the License.
   <parent>
     <groupId>org.apache.kudu</groupId>
     <artifactId>kudu-parent</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
   </parent>
 
   <groupId>com.cloudera.csd</groupId>
   <artifactId>KUDU</artifactId>
-  <version>1.0.0-SNAPSHOT</version>
+  <version>1.0.0</version>
   <name>The Kudu CSD</name>
   <packaging>pom</packaging>
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/kudu-csd/src/descriptor/service.sdl
----------------------------------------------------------------------
diff --git a/java/kudu-csd/src/descriptor/service.sdl b/java/kudu-csd/src/descriptor/service.sdl
index d07e572..94ad489 100644
--- a/java/kudu-csd/src/descriptor/service.sdl
+++ b/java/kudu-csd/src/descriptor/service.sdl
@@ -18,7 +18,7 @@
   "name" : "KUDU",
   "label" : "Kudu (Beta)",
   "description" : "Kudu is a true column store for the Hadoop ecosystem. <span class=\"error\">Kudu is currently in Beta and is not supported. Before adding this service, ensure that you have installed the Kudu binaries, which are not included in CDH.</span>",
-  "version" : "0.6.0",
+  "version" : "1.0.0",
   "compatibility" : {
     "generation" : 1
   },

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/kudu-flume-sink/pom.xml
----------------------------------------------------------------------
diff --git a/java/kudu-flume-sink/pom.xml b/java/kudu-flume-sink/pom.xml
index 7bb193c..a6e8a4e 100644
--- a/java/kudu-flume-sink/pom.xml
+++ b/java/kudu-flume-sink/pom.xml
@@ -15,7 +15,7 @@
   <parent>
     <artifactId>kudu-parent</artifactId>
     <groupId>org.apache.kudu</groupId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
   </parent>
   <artifactId>kudu-flume-sink</artifactId>
   <name>Kudu Flume NG Sink</name>

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/kudu-mapreduce/pom.xml
----------------------------------------------------------------------
diff --git a/java/kudu-mapreduce/pom.xml b/java/kudu-mapreduce/pom.xml
index b03f6da..f8d087e 100644
--- a/java/kudu-mapreduce/pom.xml
+++ b/java/kudu-mapreduce/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.kudu</groupId>
         <artifactId>kudu-parent</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0</version>
     </parent>
 
     <artifactId>kudu-mapreduce</artifactId>

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/kudu-spark/pom.xml
----------------------------------------------------------------------
diff --git a/java/kudu-spark/pom.xml b/java/kudu-spark/pom.xml
index 00635a3..17ec535 100644
--- a/java/kudu-spark/pom.xml
+++ b/java/kudu-spark/pom.xml
@@ -17,7 +17,7 @@
     <parent>
         <groupId>org.apache.kudu</groupId>
         <artifactId>kudu-parent</artifactId>
-        <version>1.0.0-SNAPSHOT</version>
+        <version>1.0.0</version>
     </parent>
 
     <artifactId>kudu-spark_${scala.binary.version}</artifactId>

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/java/pom.xml
----------------------------------------------------------------------
diff --git a/java/pom.xml b/java/pom.xml
index 9dc59a9..22340d3 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -24,7 +24,7 @@
 
     <groupId>org.apache.kudu</groupId>
     <artifactId>kudu-parent</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>pom</packaging>
 
     <!-- inherit from the ASF POM for distribution management -->

http://git-wip-us.apache.org/repos/asf/kudu/blob/b866f401/version.txt
----------------------------------------------------------------------
diff --git a/version.txt b/version.txt
index f755149..3eefcb9 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-1.0.0-SNAPSHOT
+1.0.0


[3/3] kudu git commit: [client] avoid circular deps in time-based flusher

Posted by to...@apache.org.
[client] avoid circular deps in time-based flusher

The boost::bind() makes cast of parameters during the call,
not during creation of the functor object:
  http://stackoverflow.com/questions/11255144/why-does-boostbind-store-arguments-of-the-type-passed-in-rather-than-of-the-ty

So, it's necessary to pass weak pointers to the background auto-flush
task to avoid circular dependencies between client::KuduSession::Data
and rpc::Messenger.  Besides, it does not make much sense to store
shared reference to messenger in KuduSession::Data since it's always
passed as a weak reference and then promoting to a shared one during
the call in all usage scenarios.

Thanks to Adar and Todd spotting the usual suspect there.

This is a follow-up for 93be1310d227cf05025864654ca3f6713c2ddc2c.

Change-Id: I59825981a600f5882ee476479c2ddf16b495c1f9
Reviewed-on: http://gerrit.cloudera.org:8080/4395
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins
Tested-by: Todd Lipcon <to...@apache.org>
(cherry picked from commit 1a062253e3fdc900a4b0b418520d2870b6de8846)
Reviewed-on: http://gerrit.cloudera.org:8080/4403
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/6f6e49ca
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/6f6e49ca
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/6f6e49ca

Branch: refs/heads/branch-1.0.x
Commit: 6f6e49ca98c3e3be7d81f88ab8a0f9173959b191
Parents: b866f40
Author: Alexey Serbin <as...@cloudera.com>
Authored: Mon Sep 12 18:03:27 2016 -0700
Committer: Todd Lipcon <to...@apache.org>
Committed: Tue Sep 13 07:13:21 2016 +0000

----------------------------------------------------------------------
 src/kudu/client/session-internal.cc | 20 ++++++++++----------
 src/kudu/client/session-internal.h  | 10 +++++-----
 2 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/6f6e49ca/src/kudu/client/session-internal.cc
----------------------------------------------------------------------
diff --git a/src/kudu/client/session-internal.cc b/src/kudu/client/session-internal.cc
index 8da7679..661288d 100644
--- a/src/kudu/client/session-internal.cc
+++ b/src/kudu/client/session-internal.cc
@@ -40,7 +40,7 @@ using sp::weak_ptr;
 
 
 KuduSession::Data::Data(shared_ptr<KuduClient> client,
-                        std::shared_ptr<rpc::Messenger> messenger)
+                        std::weak_ptr<rpc::Messenger> messenger)
     : client_(std::move(client)),
       messenger_(std::move(messenger)),
       error_collector_(new ErrorCollector()),
@@ -58,8 +58,8 @@ KuduSession::Data::Data(shared_ptr<KuduClient> client,
       buffer_pre_flush_enabled_(true) {
 }
 
-void KuduSession::Data::Init(const weak_ptr<KuduSession>& session) {
-  TimeBasedFlushInit(session);
+void KuduSession::Data::Init(weak_ptr<KuduSession> session) {
+  TimeBasedFlushInit(std::move(session));
 }
 
 void KuduSession::Data::FlushFinished(Batcher* batcher) {
@@ -109,7 +109,7 @@ Status KuduSession::Data::SetExternalConsistencyMode(
 }
 
 Status KuduSession::Data::SetFlushMode(FlushMode mode,
-                                       const sp::weak_ptr<KuduSession>& session) {
+                                       sp::weak_ptr<KuduSession> session) {
   {
     std::lock_guard<Mutex> l(mutex_);
     if (HasPendingOperationsUnlocked()) {
@@ -129,7 +129,7 @@ Status KuduSession::Data::SetFlushMode(FlushMode mode,
     flush_mode_ = mode;
   }
 
-  TimeBasedFlushInit(session);
+  TimeBasedFlushInit(std::move(session));
 
   return Status::OK();
 }
@@ -320,7 +320,7 @@ MonoDelta KuduSession::Data::FlushCurrentBatcher(const MonoDelta& max_age) {
 // batcher (success path) or in the error collector (failure path). Otherwise
 // it would be a memory leak.
 Status KuduSession::Data::ApplyWriteOp(
-    const sp::weak_ptr<KuduSession>& weak_session,
+    sp::weak_ptr<KuduSession> weak_session,
     KuduWriteOperation* write_op) {
 
   if (!write_op) {
@@ -429,7 +429,7 @@ Status KuduSession::Data::ApplyWriteOp(
       // of control since no thread-safety is advertised
       // for the kudu::KuduSession interface.
       scoped_refptr<Batcher> batcher(
-          new Batcher(client_.get(), error_collector_, weak_session,
+          new Batcher(client_.get(), error_collector_, std::move(weak_session),
                       external_consistency_mode_));
       if (timeout_ms_ != -1) {
         batcher->SetTimeoutMillis(timeout_ms_);
@@ -462,7 +462,7 @@ Status KuduSession::Data::ApplyWriteOp(
 void KuduSession::Data::TimeBasedFlushInit(
     sp::weak_ptr<KuduSession> weak_session) {
   KuduSession::Data::TimeBasedFlushTask(
-      Status::OK(), messenger_, weak_session, true);
+      Status::OK(), messenger_, std::move(weak_session), true);
 }
 
 void KuduSession::Data::TimeBasedFlushTask(
@@ -513,8 +513,8 @@ void KuduSession::Data::TimeBasedFlushTask(
   std::shared_ptr<rpc::Messenger> messenger(weak_messenger.lock());
   if (PREDICT_TRUE(messenger)) {
     messenger->ScheduleOnReactor(
-        boost::bind(&KuduSession::Data::TimeBasedFlushTask,
-                    _1, messenger, session, false),
+        boost::bind(&KuduSession::Data::TimeBasedFlushTask, _1,
+                    std::move(weak_messenger), std::move(weak_session), false),
         next_run);
   }
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/6f6e49ca/src/kudu/client/session-internal.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/session-internal.h b/src/kudu/client/session-internal.h
index e050301..fe2225c 100644
--- a/src/kudu/client/session-internal.h
+++ b/src/kudu/client/session-internal.h
@@ -55,9 +55,9 @@ class ErrorCollector;
 class KuduSession::Data {
  public:
   explicit Data(sp::shared_ptr<KuduClient> client,
-                std::shared_ptr<rpc::Messenger> messenger);
+                std::weak_ptr<rpc::Messenger> messenger);
 
-  void Init(const sp::weak_ptr<KuduSession>& session);
+  void Init(sp::weak_ptr<KuduSession> session);
 
   // Called by Batcher when a flush has finished.
   void FlushFinished(internal::Batcher* b);
@@ -68,7 +68,7 @@ class KuduSession::Data {
   Status Close(bool force);
 
   // Set flush mode for the session.
-  Status SetFlushMode(FlushMode mode, const sp::weak_ptr<KuduSession>& session);
+  Status SetFlushMode(FlushMode mode, sp::weak_ptr<KuduSession> session);
 
   // Set external consistency mode for the session.
   Status SetExternalConsistencyMode(KuduSession::ExternalConsistencyMode m);
@@ -123,7 +123,7 @@ class KuduSession::Data {
   MonoDelta FlushCurrentBatcher(const MonoDelta& max_age);
 
   // Apply a write operation, i.e. push it through the batcher chain.
-  Status ApplyWriteOp(const sp::weak_ptr<KuduSession>& session,
+  Status ApplyWriteOp(sp::weak_ptr<KuduSession> session,
                       KuduWriteOperation* write_op);
 
   // Check and start the time-based flush task in background, if necessary.
@@ -160,7 +160,7 @@ class KuduSession::Data {
 
   // The reference to the client's messenger (keeping the reference instead of
   // declaring friendship to KuduClient and accessing it via the client_).
-  std::shared_ptr<rpc::Messenger> messenger_;
+  std::weak_ptr<rpc::Messenger> messenger_;
 
   // Buffer for errors.
   scoped_refptr<internal::ErrorCollector> error_collector_;