From 3c0d0826fd92c56316fe6f0f1562d67805e0c401 Mon Sep 17 00:00:00 2001 From: Will Berkeley Date: Sat, 24 Mar 2018 20:42:21 -0700 Subject: [PATCH] repro for segfault while add/drop partition with concurrent writes Change-Id: I100ece023fcb597f20e3ba03bef4b675fd345555 --- src/kudu/integration-tests/alter_table-test.cc | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/src/kudu/integration-tests/alter_table-test.cc b/src/kudu/integration-tests/alter_table-test.cc index f7712091b..0080fa9f4 100644 --- a/src/kudu/integration-tests/alter_table-test.cc +++ b/src/kudu/integration-tests/alter_table-test.cc @@ -70,6 +70,7 @@ #include "kudu/util/test_macros.h" #include "kudu/util/test_util.h" #include "kudu/util/thread.h" +#include "kudu/integration-tests/test_workload.h" DECLARE_bool(enable_maintenance_manager); DECLARE_int32(heartbeat_interval_ms); @@ -1277,6 +1278,61 @@ TEST_F(AlterTableTest, TestMultipleAlters) { ASSERT_EQ(kNumNewCols + schema_.num_columns(), new_schema.num_columns()); } +TEST_F(AlterTableTest, TestAlterRangePartitioningConcurrentWrites) { + // Redo the schema with the key column named "key" for the TestWorkload. + KuduSchema schema; + KuduSchemaBuilder b; + b.AddColumn("key")->Type(KuduColumnSchema::INT32)->NotNull()->PrimaryKey(); + b.AddColumn("c1")->Type(KuduColumnSchema::INT32)->NotNull(); + CHECK_OK(b.Build(&schema)); + + // Set a large upper bound so the workload won't try to write beyond it. + long ub = 1000000000; + unique_ptr lower(schema.NewRow()); + unique_ptr upper(schema.NewRow()); + ASSERT_OK(lower->SetInt32("key", 0)); + ASSERT_OK(upper->SetInt32("key", ub)); + string table_name = "test-alter-range-partitioning-replace-partition"; + unique_ptr table_creator(client_->NewTableCreator()); + ASSERT_OK(table_creator->table_name(table_name) + .schema(&schema) + .set_range_partition_columns({ "key" }) + .add_hash_partitions({ "key" }, 2) + .add_range_partition_split(lower.release()) + .add_range_partition_split(upper.release()) + .num_replicas(1) + .Create()); + shared_ptr table; + ASSERT_OK(client_->OpenTable(table_name, &table)); + + // Write throughout. + TestWorkload workload(cluster_.get()); + workload.set_table_name(table_name); + workload.set_schema(schema); + workload.Setup(); + workload.Start(); + + // Drop and add the same range partition. + unique_ptr table_alterer; + table_alterer.reset(client_->NewTableAlterer(table_name)); + lower.reset(schema.NewRow()); + upper.reset(schema.NewRow()); + ASSERT_OK(lower->SetInt32("key", 0)); + ASSERT_OK(upper->SetInt32("key", ub)); + table_alterer->DropRangePartition(lower.release(), upper.release()); + lower.reset(schema.NewRow()); + upper.reset(schema.NewRow()); + ASSERT_OK(lower->SetInt32("key", 0)); + ASSERT_OK(upper->SetInt32("key", ub)); + table_alterer->AddRangePartition(lower.release(), upper.release()); + ASSERT_OK(table_alterer->wait(true)->Alter()); + + // Sleep for a bit so more writes happen. + SleepFor(MonoDelta::FromSeconds(2)); + workload.StopAndJoin(); +} + + TEST_F(AlterTableTest, TestAlterRangePartitioning) { unique_ptr table_alterer; -- 2.16.2