kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [kudu] 01/04: tablet copy client: delete WAL data using existing function
Date Tue, 21 Jan 2020 22:41:09 GMT
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 07e36221b8d8b3ce48690e40181a51a6953323b8
Author: Adar Dembo <adar@cloudera.com>
AuthorDate: Sun Jan 19 16:09:59 2020 -0800

    tablet copy client: delete WAL data using existing function
    
    I thought this might be needed for correctness (if Log::DeleteOnDiskData did
    something beyond a recursive deletion), but it's not. Nevertheless, it seems
    more robust, if DeleteOnDiskData _did_ were changed to do something
    interesting in the future.
    
    Change-Id: Ic18d11a3d857ab9a29a82d9f7ebe72f33737e25d
    Reviewed-on: http://gerrit.cloudera.org:8080/15077
    Reviewed-by: Andrew Wong <awong@cloudera.com>
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <aserbin@cloudera.com>
---
 src/kudu/tserver/tablet_copy_client.cc | 11 +++++------
 src/kudu/tserver/tablet_copy_client.h  |  6 ++++--
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/kudu/tserver/tablet_copy_client.cc b/src/kudu/tserver/tablet_copy_client.cc
index a80993b..d5e4a2c 100644
--- a/src/kudu/tserver/tablet_copy_client.cc
+++ b/src/kudu/tserver/tablet_copy_client.cc
@@ -24,8 +24,8 @@
 
 #include <boost/optional/optional.hpp>
 #include <gflags/gflags.h>
-#include <gflags/gflags_declare.h>
 #include <glog/logging.h>
+#include <google/protobuf/stubs/port.h>
 
 #include "kudu/common/common.pb.h"
 #include "kudu/common/partition.h"
@@ -33,6 +33,7 @@
 #include "kudu/common/wire_protocol.h"
 #include "kudu/consensus/consensus_meta.h"
 #include "kudu/consensus/consensus_meta_manager.h"
+#include "kudu/consensus/log.h"
 #include "kudu/consensus/metadata.pb.h"
 #include "kudu/consensus/opid.pb.h"
 #include "kudu/consensus/opid_util.h"
@@ -148,7 +149,8 @@ TabletCopyClientMetrics::TabletCopyClientMetrics(const scoped_refptr<MetricEntit
       open_client_sessions(METRIC_tablet_copy_open_client_sessions.Instantiate(metric_entity,
0)) {
 }
 
-TabletCopyClient::TabletCopyClient(std::string tablet_id,
+TabletCopyClient::TabletCopyClient(
+    std::string tablet_id,
     FsManager* fs_manager,
     scoped_refptr<ConsensusMetadataManager> cmeta_manager,
     shared_ptr<Messenger> messenger,
@@ -159,7 +161,6 @@ TabletCopyClient::TabletCopyClient(std::string tablet_id,
       messenger_(std::move(messenger)),
       state_(kInitialized),
       replace_tombstoned_tablet_(false),
-      tablet_replica_(nullptr),
       session_idle_timeout_millis_(FLAGS_tablet_copy_begin_session_timeout_ms),
       start_time_micros_(0),
       rng_(GetRandomSeed32()),
@@ -532,10 +533,8 @@ Status TabletCopyClient::DownloadWALs() {
 
   // Delete and recreate WAL dir if it already exists, to ensure stray files are
   // not kept from previous copies and runs.
+  RETURN_NOT_OK(log::Log::DeleteOnDiskData(fs_manager_, tablet_id_));
   string path = fs_manager_->GetTabletWalDir(tablet_id_);
-  if (fs_manager_->env()->FileExists(path)) {
-    RETURN_NOT_OK(fs_manager_->env()->DeleteRecursively(path));
-  }
   RETURN_NOT_OK(fs_manager_->env()->CreateDir(path));
   RETURN_NOT_OK(fs_manager_->env()->SyncDir(DirName(path))); // fsync() parent dir.
 
diff --git a/src/kudu/tserver/tablet_copy_client.h b/src/kudu/tserver/tablet_copy_client.h
index c2adf6a..27ed996 100644
--- a/src/kudu/tserver/tablet_copy_client.h
+++ b/src/kudu/tserver/tablet_copy_client.h
@@ -80,8 +80,10 @@ class TabletCopyClient {
  public:
 
   // Construct the tablet copy client.
-  // 'fs_manager' and 'messenger' must remain valid until this object is destroyed.
-  TabletCopyClient(std::string tablet_id, FsManager* fs_manager,
+  //
+  // Objects behind raw pointers must remain valid until this object is destroyed.
+  TabletCopyClient(std::string tablet_id,
+                   FsManager* fs_manager,
                    scoped_refptr<consensus::ConsensusMetadataManager> cmeta_manager,
                    std::shared_ptr<rpc::Messenger> messenger,
                    TabletCopyClientMetrics* tablet_copy_metrics);


Mime
View raw message