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 0a3d12c [test] add ReplicatedAlterTableTest.AlterTableAndDropTablet
0a3d12c is described below
commit 0a3d12c0340346ae5adfe92b5d809bbbc31be089
Author: Alexey Serbin <[email protected]>
AuthorDate: Thu Oct 8 23:18:33 2020 -0700
[test] add ReplicatedAlterTableTest.AlterTableAndDropTablet
This patch adds a new test scenario to verify that a set of DDL
operations (e.g., ALTER TABLE adding a new column) followed by dropping
a tablet are processed with now issues even in case of slow WAL.
In addition, this scenario covers the regression fixed with changelist
81f0dbf99.
I manually verified that the test fails (i.e. the process crashes)
with the stack trace as below if rolling back changelist 81f0dbf99
(macOS DEBUG build):
I1009 00:11:52.782909 263938048 op_tracker.cc:285] Dumping up to 50
currently running ops:
Assertion failed: (this->is_initialized()), function operator->, file
/Users/aserbin/Projects/kudu/thirdparty/installed/uninstrumented/include/boost/optional/optional.hpp,
line 1221.
*** Aborted at 1602227512 (unix time) try "date -d @1602227512" if you
are using GNU date ***
PC: @ 0x7fff79a74b66 __pthread_kill
*** SIGABRT (@0x7fff79a74b66) received by PID 67923 (TID 0x70000fbb6000)
stack trace: ***
@ 0x7fff79c32f5a _sigtramp
@ 0x10f17a3f5 google::protobuf::TextFormat::Printer::Print()
@ 0x7fff799d01ae abort
@ 0x7fff799981ac __assert_rtn
@ 0x10c2a4c9d boost::optional<>::operator->()
@ 0x10c2a49e5 kudu::tablet::AlterSchemaOpState::ToString()
@ 0x10c2a6b0c kudu::tablet::AlterSchemaOp::ToString()
@ 0x10c2ab03e kudu::tablet::OpDriver::ToStringUnlocked()
@ 0x10c2aaec8 kudu::tablet::OpDriver::ToString()
@ 0x10c2bb653 kudu::tablet::OpTracker::WaitForAllToFinish()
@ 0x10c2baca2 kudu::tablet::OpTracker::WaitForAllToFinish()
@ 0x10c272a5f kudu::tablet::TabletReplica::Stop()
@ 0x109d3524c kudu::tserver::TSTabletManager::DeleteTablet()
@ 0x109d5d542 kudu::tserver::DeleteTabletRunnable::Run()
@ 0x109d5e9f1
kudu::tserver::TSTabletManager::DeleteTabletAsync()::$_14::operator()()
@ 0x109d5e9bd
_ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN4kudu7tserver15TSTabletManager17DeleteTabletAsyncERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEENS3_6tablet15TabletDataStateERKN5boost8optionalIxEERKNS_8functionIFvRKNS3_6StatusENS4_24TabletServerErrorPB_CodeEEEEE4$_14EEEvDpOT_
@ 0x109d5e6f9 std::__1::__function::__func<>::operator()()
@ 0x10913ef46 std::__1::function<>::operator()()
@ 0x10e7c22cd kudu::ThreadPool::DispatchThread()
@ 0x10e7de7f8
kudu::ThreadPool::CreateThread()::$_1::operator()()
@ 0x10e7de7cd
_ZNSt3__128__invoke_void_return_wrapperIvE6__callIJRZN4kudu10ThreadPool12CreateThreadEvE3$_1EEEvDpOT_
@ 0x10e7de6e9 std::__1::__function::__func<>::operator()()
@ 0x10913ef46 std::__1::function<>::operator()()
@ 0x10e7a3275 kudu::Thread::SuperviseThread()
@ 0x7fff79c3c661 _pthread_body
@ 0x7fff79c3c50d _pthread_start
@ 0x7fff79c3bbf9 thread_start
Change-Id: I264e9873399ede60b642bde1a1e9c343dfa44072
Reviewed-on: http://gerrit.cloudera.org:8080/16570
Reviewed-by: Andrew Wong <[email protected]>
Tested-by: Kudu Jenkins
---
src/kudu/integration-tests/alter_table-test.cc | 83 +++++++++++++++++++++-----
1 file changed, 67 insertions(+), 16 deletions(-)
diff --git a/src/kudu/integration-tests/alter_table-test.cc
b/src/kudu/integration-tests/alter_table-test.cc
index 69dc64e..3dad23f 100644
--- a/src/kudu/integration-tests/alter_table-test.cc
+++ b/src/kudu/integration-tests/alter_table-test.cc
@@ -72,10 +72,12 @@
#include "kudu/util/test_util.h"
DECLARE_bool(enable_maintenance_manager);
-DECLARE_int32(heartbeat_interval_ms);
-DECLARE_int32(flush_threshold_mb);
-DECLARE_bool(use_hybrid_clock);
+DECLARE_bool(log_inject_latency);
DECLARE_bool(scanner_allow_snapshot_scans_with_logical_timestamps);
+DECLARE_bool(use_hybrid_clock);
+DECLARE_int32(flush_threshold_mb);
+DECLARE_int32(heartbeat_interval_ms);
+DECLARE_int32(log_inject_latency_ms_mean);
using kudu::client::CountTableRows;
using kudu::client::KuduClient;
@@ -109,6 +111,7 @@ using std::string;
using std::thread;
using std::unique_ptr;
using std::vector;
+using strings::Substitute;
namespace kudu {
@@ -226,7 +229,7 @@ class AlterTableTest : public KuduTest {
const MonoDelta& timeout) {
unique_ptr<KuduTableAlterer>
table_alterer(client_->NewTableAlterer(table_name));
table_alterer->AddColumn(column_name)->Type(KuduColumnSchema::INT32)->
- NotNull()->Default(KuduValue::FromInt(default_value));
+ NotNull()->Default(KuduValue::FromInt(default_value));
return table_alterer->timeout(timeout)->Alter();
}
@@ -288,7 +291,7 @@ class AlterTableTest : public KuduTest {
protected:
virtual int num_replicas() const { return 1; }
- static const char *kTableName;
+ static const char* const kTableName;
unique_ptr<InternalMiniCluster> cluster_;
shared_ptr<KuduClient> client_;
@@ -313,7 +316,7 @@ class ReplicatedAlterTableTest : public AlterTableTest {
virtual int num_replicas() const OVERRIDE { return 3; }
};
-const char *AlterTableTest::kTableName = "fake-table";
+const char* const AlterTableTest::kTableName = "fake-table";
// Simple test to verify that the "alter table" command sent and executed
// on the TS handling the tablet of the altered table.
@@ -1215,9 +1218,7 @@ TEST_F(AlterTableTest, TestAlterUnderWriteLoad) {
SleepFor(MonoDelta::FromSeconds(3));
}
- ASSERT_OK(AddNewI32Column(kTableName,
- strings::Substitute("c$0", i),
- i));
+ ASSERT_OK(AddNewI32Column(kTableName, Substitute("c$0", i), i));
}
// A sanity check: the updater should have generate at least one update
@@ -1277,7 +1278,7 @@ TEST_F(AlterTableTest, TestMultipleAlters) {
// Issue a bunch of new alters without waiting for them to finish.
for (int i = 0; i < kNumNewCols; i++) {
unique_ptr<KuduTableAlterer>
table_alterer(client_->NewTableAlterer(kSplitTableName));
- table_alterer->AddColumn(strings::Substitute("new_col$0", i))
+ table_alterer->AddColumn(Substitute("new_col$0", i))
->Type(KuduColumnSchema::INT32)->NotNull()
->Default(KuduValue::FromInt(kDefaultValue));
ASSERT_OK(table_alterer->wait(false)->Alter());
@@ -1841,12 +1842,12 @@ TEST_F(AlterTableTest,
TestAddRangePartitionConflictExhaustive) {
return "UNBOUNDED";
}
if (!lower_bound) {
- return strings::Substitute("VALUES < $0", *upper_bound);
+ return Substitute("VALUES < $0", *upper_bound);
}
if (!upper_bound) {
- return strings::Substitute("VALUES >= $0", *lower_bound);
+ return Substitute("VALUES >= $0", *lower_bound);
}
- return strings::Substitute("$0 <= VALUES < $1", *lower_bound,
*upper_bound);
+ return Substitute("$0 <= VALUES < $1", *lower_bound, *upper_bound);
};
// Checks that b conflicts with a, when added in that order.
@@ -1854,8 +1855,8 @@ TEST_F(AlterTableTest,
TestAddRangePartitionConflictExhaustive) {
boost::optional<int32_t>
a_upper_bound,
boost::optional<int32_t>
b_lower_bound,
boost::optional<int32_t>
b_upper_bound) {
- SCOPED_TRACE(strings::Substitute("b: $0", bounds_to_string(b_lower_bound,
b_upper_bound)));
- SCOPED_TRACE(strings::Substitute("a: $0", bounds_to_string(a_lower_bound,
a_upper_bound)));
+ SCOPED_TRACE(Substitute("b: $0", bounds_to_string(b_lower_bound,
b_upper_bound)));
+ SCOPED_TRACE(Substitute("a: $0", bounds_to_string(a_lower_bound,
a_upper_bound)));
// Add a then add b.
ASSERT_OK(add_range_partition(a_lower_bound, a_upper_bound));
@@ -2098,6 +2099,57 @@ TEST_F(ReplicatedAlterTableTest, TestReplicatedAlter) {
});
}
+// This scenario verifies that many DDL operations (e.g., ALTER TABLE adding
+// a new column) followed by dropping a tablet are processed with no issues
+// even in case of slow WAL. In addition, this scenario covers the regression
+// fixed with changelist 81f0dbf99ac2114a29431f49fa2ef480e7ef26c4.
+TEST_F(ReplicatedAlterTableTest, AlterTableAndDropTablet) {
+ SKIP_IF_SLOW_NOT_ALLOWED();
+
+#if defined(THREAD_SANITIZER) || defined(ADDRESS_SANITIZER)
+ constexpr int32_t kIterNum = 10;
+#else
+ constexpr int32_t kIterNum = 50;
+#endif
+
+ static constexpr const char* const kTableName = "many-ranges-table";
+ const auto fill_row = [&] (int32_t value) {
+ unique_ptr<KuduPartialRow> row(schema_.NewRow());
+ CHECK_OK(row->SetInt32("c0", value));
+ return row;
+ };
+
+ {
+ vector<pair<unique_ptr<KuduPartialRow>, unique_ptr<KuduPartialRow>>>
bounds;
+ bounds.emplace_back(fill_row(0), fill_row(1));
+ ASSERT_OK(CreateTable(kTableName, schema_, {"c0"}, {}, std::move(bounds)));
+ }
+
+ for (auto i = 1; i < kIterNum; ++i) {
+ unique_ptr<KuduTableAlterer> ta(client_->NewTableAlterer(kTableName));
+ ASSERT_OK(ta->AddRangePartition(
+ fill_row(i).release(),
+ fill_row(i + 1).release())->wait(true)->Alter());
+ }
+
+ FLAGS_log_inject_latency = true;
+ FLAGS_log_inject_latency_ms_mean = 250;
+
+ for (auto i = 0; i < kIterNum; ++i) {
+ unique_ptr<KuduTableAlterer> ta(client_->NewTableAlterer(kTableName));
+ ta->AddColumn(Substitute("new_c$0", i))->Type(KuduColumnSchema::INT32);
+ ASSERT_OK(ta->wait(false)->Alter());
+ }
+
+ for (auto i = 0; i < kIterNum; ++i) {
+ unique_ptr<KuduTableAlterer> ta(client_->NewTableAlterer(kTableName));
+ ASSERT_OK(ta->DropRangePartition(
+ fill_row(i).release(),
+ fill_row(i + 1).release())->wait(false)->Alter());
+ }
+ ASSERT_OK(client_->DeleteTable(kTableName));
+}
+
TEST_F(AlterTableTest, TestRenameStillCreatingTable) {
const string kNewTableName = "foo";
@@ -2159,5 +2211,4 @@ TEST_F(AlterTableTest, TestMaintenancePriorityAlter) {
NO_FATALS(CheckMaintenancePriority(0));
}
-
} // namespace kudu