This is an automated email from the ASF dual-hosted git repository. abukor pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit ca56ee56eb14ea4e91e0ec20b5b8cd857b60423c Author: Alexey Serbin <[email protected]> AuthorDate: Fri May 3 10:51:18 2024 -0700 KUDU-3216 fix flakiness in LeadershipChangeOnTskGeneration Before this patch, the LeadershipChangeOnTskGeneration scenario from CatalogManagerTskITest would fail once in about 50 runs, DEBUG build. With this patch, the test scenario hasn't had a single failure in about 300 runs, DEBUG build. Change-Id: I139e46627206fc13490ca405bb62dc29934dc4be Reviewed-on: http://gerrit.cloudera.org:8080/21397 Reviewed-by: Wang Xixu <[email protected]> Reviewed-by: Attila Bukor <[email protected]> Tested-by: Attila Bukor <[email protected]> --- .../integration-tests/catalog_manager_tsk-itest.cc | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/kudu/integration-tests/catalog_manager_tsk-itest.cc b/src/kudu/integration-tests/catalog_manager_tsk-itest.cc index cceb1aa07..ec4d1e8c6 100644 --- a/src/kudu/integration-tests/catalog_manager_tsk-itest.cc +++ b/src/kudu/integration-tests/catalog_manager_tsk-itest.cc @@ -124,11 +124,28 @@ class CatalogManagerTskITest : public KuduTest { auto schema = KuduSchema::FromSchema(CreateKeyValueTestSchema()); unique_ptr<KuduTableCreator> table_creator(client->NewTableCreator()); - ASSERT_OK(table_creator->table_name(kTableName) - .set_range_partition_columns({ "key" }) - .schema(&schema) - .num_replicas(num_tservers_) - .Create()); + Status tc_status; + for (auto i = 0; i < 10; ++i) { + // Sometimes, CreateTable requests might arrive when a new system tablet + // leader replica hasn't yet replicated NO_OP after establishing its + // leadership in a new Raft term. The test is based on ExternalMiniCluster + // where a dedicated API to check for the presence of particular entries + // in the WAL is absent. Instead, let's retry CreateTable upon receiving + // an error of a particular type and check for the error message: it's + // good enough for a test. + tc_status = table_creator->table_name(kTableName) + .set_range_partition_columns({ "key" }) + .schema(&schema) + .num_replicas(num_tservers_) + .Create(); + if (tc_status.ok()) { + break; + } + ASSERT_TRUE(tc_status.IsServiceUnavailable()) << tc_status.ToString(); + ASSERT_STR_CONTAINS(tc_status.ToString(), "leader is not yet ready"); + SleepFor(MonoDelta::FromMilliseconds(100)); + } + ASSERT_OK(tc_status); // Insert a row. shared_ptr<KuduTable> table;
