This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 0967b895a [tests] re-enable ReplaceTabletsWhileWriting scenario
0967b895a is described below

commit 0967b895a06f2b5b509db0ea2786d1ba721030d1
Author: Alexey Serbin <[email protected]>
AuthorDate: Wed Jul 24 18:03:49 2024 -0700

    [tests] re-enable ReplaceTabletsWhileWriting scenario
    
    Since KUDU-2376 seems to be a duplicate of KUDU-3461, and the latter
    has already been addressed, it makes sense to re-enable the
    ReplaceTabletITest.ReplaceTabletsWhileWriting scenario which is
    now passing with this patch.
    
    TestWorkload updated to allow for Status::InvalidAgrument status
    that percolates from the client's meta-cache when a tablet is replaced.
    This patch also contains other minor (mostly cosmetic) updates.
    
    Change-Id: I36b0e69022f07dd701a91e72e16c93f134d00619
    Reviewed-on: http://gerrit.cloudera.org:8080/21612
    Tested-by: Alexey Serbin <[email protected]>
    Reviewed-by: Ashwani Raina <[email protected]>
    Reviewed-by: Abhishek Chennaka <[email protected]>
---
 src/kudu/client/client-test.cc                     |  6 ++++--
 src/kudu/client/meta_cache.cc                      | 16 ++++++++--------
 src/kudu/integration-tests/CMakeLists.txt          |  2 +-
 src/kudu/integration-tests/replace_tablet-itest.cc |  7 ++-----
 src/kudu/integration-tests/test_workload.cc        | 20 ++++++++++++--------
 src/kudu/integration-tests/test_workload.h         | 11 ++++++++++-
 6 files changed, 37 insertions(+), 25 deletions(-)

diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc
index 0f08ebbff..d3372920a 100644
--- a/src/kudu/client/client-test.cc
+++ b/src/kudu/client/client-test.cc
@@ -551,8 +551,10 @@ class ClientTest : public KuduTest {
     ASSERT_EQ(errors.size(), num_rows);
 
     // Check for only the first error.
-    ASSERT_TRUE(errors[0]->status().IsInvalidArgument());
-    ASSERT_STR_CONTAINS(errors[0]->status().ToString(), "Tablet id is not 
valid anymore");
+    ASSERT_GE(errors.size(), 1);
+    const auto& s = errors[0]->status();
+    ASSERT_TRUE(s.IsInvalidArgument()) << s.ToString();
+    ASSERT_STR_MATCHES(s.ToString(), "tablet ID .* is not valid");
   }
 
   // Inserts 'num_rows' using the default client.
diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc
index 2ddfdf6c4..17f77d63a 100644
--- a/src/kudu/client/meta_cache.cc
+++ b/src/kudu/client/meta_cache.cc
@@ -551,15 +551,15 @@ void MetaCacheServerPicker::PickLeader(const 
ServerPickedCallback& callback,
           VLOG(2) << Substitute("Explicit fastpath lookup succeeded(maybe), "
                                 "proceed with callback, table: $0",
                                 table_->name());
-          if (remote_tablet &&
-              remote_tablet->tablet_id() != tablet_->tablet_id()) {
+          const auto& known_tablet_id = tablet_->tablet_id();
+          if (remote_tablet && remote_tablet->tablet_id() != known_tablet_id) {
             // Skip further processing if tablet in question has turned invalid
-            LOG(INFO) << Substitute("Tablet under process found to be invalid, 
"
-                                    "table: $0 - old tabletid: $1, new 
tabletid: $2",
-                                    table_->name(), tablet_->tablet_id(),
-                                    remote_tablet->tablet_id());
-            callback(Status::InvalidArgument("Tablet id is not valid anymore"),
-                                             nullptr);
+            LOG(INFO) << Substitute(
+                "tablet seems to be replaced: former ID $0, new ID $1 (table 
$2)",
+                known_tablet_id, remote_tablet->tablet_id(), table_->name());
+            callback(Status::InvalidArgument(
+                         Substitute("tablet ID $0 is not valid", 
known_tablet_id)),
+                     nullptr);
             return;
           }
         }
diff --git a/src/kudu/integration-tests/CMakeLists.txt 
b/src/kudu/integration-tests/CMakeLists.txt
index 9dd934dc8..36a352a5f 100644
--- a/src/kudu/integration-tests/CMakeLists.txt
+++ b/src/kudu/integration-tests/CMakeLists.txt
@@ -115,7 +115,7 @@ ADD_KUDU_TEST(raft_consensus_failure_detector-imc-itest)
 ADD_KUDU_TEST(raft_consensus_nonvoter-itest PROCESSORS 3)
 ADD_KUDU_TEST(raft_consensus_stress-itest RUN_SERIAL true)
 ADD_KUDU_TEST(raft_consensus-itest RUN_SERIAL true NUM_SHARDS 6)
-ADD_KUDU_TEST(replace_tablet-itest)
+ADD_KUDU_TEST(replace_tablet-itest PROCESSORS 4)
 ADD_KUDU_TEST(registration-test RESOURCE_LOCK "master-web-port")
 ADD_KUDU_TEST(same_tablet_concurrent_writes-itest)
 ADD_KUDU_TEST(security-faults-itest)
diff --git a/src/kudu/integration-tests/replace_tablet-itest.cc 
b/src/kudu/integration-tests/replace_tablet-itest.cc
index 3f866074f..0ae1ba9a9 100644
--- a/src/kudu/integration-tests/replace_tablet-itest.cc
+++ b/src/kudu/integration-tests/replace_tablet-itest.cc
@@ -33,7 +33,6 @@
 #include "kudu/master/master.pb.h"
 #include "kudu/master/master.proxy.h"
 #include "kudu/mini-cluster/external_mini_cluster.h"
-#include "kudu/rpc/response_callback.h"
 #include "kudu/tablet/tablet.pb.h"
 #include "kudu/tools/tool_action_common.h"
 #include "kudu/tserver/tserver.pb.h"
@@ -88,10 +87,7 @@ class ReplaceTabletITest : public 
ExternalMiniClusterITestBase {
   Random rand_;
 };
 
-// TODO(wdberkeley): Enable this test once KUDU-2376 is fixed.
-// TODO(wdberkeley): Set the PROCESSOR configuration properly for this test 
once
-//                   it is enabled. See 1c1d3ba.
-TEST_F(ReplaceTabletITest, DISABLED_ReplaceTabletsWhileWriting) {
+TEST_F(ReplaceTabletITest, ReplaceTabletsWhileWriting) {
   constexpr int kNumTabletServers = 3;
   constexpr int kNumTablets = 4;
   constexpr int kNumRows = 10000;
@@ -111,6 +107,7 @@ TEST_F(ReplaceTabletITest, 
DISABLED_ReplaceTabletsWhileWriting) {
   TestWorkload workload(cluster_.get());
   workload.set_num_replicas(kNumTabletServers);
   workload.set_num_tablets(kNumTablets);
+  workload.set_invalid_argument_allowed(true);
   workload.Setup();
 
   // Insert some rows before replacing tablets so the client's cache is warm.
diff --git a/src/kudu/integration-tests/test_workload.cc 
b/src/kudu/integration-tests/test_workload.cc
index 5b6965769..d019ee673 100644
--- a/src/kudu/integration-tests/test_workload.cc
+++ b/src/kudu/integration-tests/test_workload.cc
@@ -20,6 +20,7 @@
 #include <memory>
 #include <ostream>
 #include <string>
+#include <type_traits>
 
 #include <glog/logging.h>
 
@@ -88,6 +89,7 @@ TestWorkload::TestWorkload(MiniCluster* cluster,
     timeout_allowed_(false),
     not_found_allowed_(false),
     already_present_allowed_(false),
+    invalid_argument_allowed_(false),
     network_error_allowed_(false),
     remote_error_allowed_(false),
     write_pattern_(INSERT_RANDOM_ROWS),
@@ -284,21 +286,23 @@ void TestWorkload::ReadThread() {
 
 #undef CHECK_READ_OK
 
-size_t TestWorkload::GetNumberOfErrors(KuduSession* session) {
+size_t TestWorkload::GetNumberOfErrors(KuduSession* session) const {
   vector<KuduError*> errors;
   ElementDeleter d(&errors);
   bool overflow;
   session->GetPendingErrors(&errors, &overflow);
   CHECK(!overflow);
-  for (const KuduError* e : errors) {
-    if ((timeout_allowed_ && e->status().IsTimedOut()) ||
-        (not_found_allowed_ && e->status().IsNotFound()) ||
-        (already_present_allowed_ && e->status().IsAlreadyPresent()) ||
-        (network_error_allowed_ && e->status().IsNetworkError()) ||
-        (remote_error_allowed_ && e->status().IsRemoteError())) {
+  for (const auto* e : errors) {
+    const auto& s = e->status();
+    if ((timeout_allowed_ && s.IsTimedOut()) ||
+        (not_found_allowed_ && s.IsNotFound()) ||
+        (already_present_allowed_ && s.IsAlreadyPresent()) ||
+        (invalid_argument_allowed_ && s.IsInvalidArgument()) ||
+        (network_error_allowed_ && s.IsNetworkError()) ||
+        (remote_error_allowed_ && s.IsRemoteError())) {
       continue;
     }
-    LOG(FATAL) << e->status().ToString();
+    LOG(FATAL) << s.ToString();
   }
   return errors.size();
 }
diff --git a/src/kudu/integration-tests/test_workload.h 
b/src/kudu/integration-tests/test_workload.h
index 4949c60b1..c9adfb376 100644
--- a/src/kudu/integration-tests/test_workload.h
+++ b/src/kudu/integration-tests/test_workload.h
@@ -208,6 +208,14 @@ class TestWorkload {
     already_present_allowed_ = allowed;
   }
 
+  // Whether per-row errors with Status::InvalidArgument() are allowed: these
+  // might be coming out of client's metacache when a particular tablet
+  // is replaced (see KUDU-3461 for details).
+  // By default this triggers a check failure.
+  void set_invalid_argument_allowed(bool allowed) {
+    invalid_argument_allowed_ = allowed;
+  }
+
   // Override the default "simple" schema.
   void set_schema(const client::KuduSchema& schema);
 
@@ -335,7 +343,7 @@ class TestWorkload {
   void OpenTable(client::sp::shared_ptr<client::KuduTable>* table);
   void WriteThread();
   void ReadThread();
-  size_t GetNumberOfErrors(client::KuduSession* session);
+  size_t GetNumberOfErrors(client::KuduSession* session) const;
 
   cluster::MiniCluster* cluster_;
   const PartitioningType partitioning_;
@@ -361,6 +369,7 @@ class TestWorkload {
   bool timeout_allowed_;
   bool not_found_allowed_;
   bool already_present_allowed_;
+  bool invalid_argument_allowed_;
   bool network_error_allowed_;
   bool remote_error_allowed_;
   WritePattern write_pattern_;

Reply via email to