Repository: kudu Updated Branches: refs/heads/master f5c802ced -> 95182a6df
KUDU-2191: Adjust upgrade tool to tolerate downgraded metadata Currently, TestHmsDowngrade keeps on failing as the metadata upgrade tool does not handle tables being downgraded properly. This issue didn't surface because commit 214dbc249 didn't rebase. This commit corrects the upgrade tool to better handle this scenario. I also looped this test for 500 times, no failures found for TestHmsDowngrade. Dist-test: http://dist-test.cloudera.org/job?job_id=hao.hao.1530566672.124129 Change-Id: Ie9a3b154e77db4eda72b9c4b53861f9fe06f09a3 Reviewed-on: http://gerrit.cloudera.org:8080/10844 Reviewed-by: Andrew Wong <aw...@cloudera.com> Tested-by: Kudu Jenkins Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/95182a6d Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/95182a6d Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/95182a6d Branch: refs/heads/master Commit: 95182a6dff9da1f268d60aed705a267ed2946df6 Parents: f5c802c Author: Hao Hao <hao....@cloudera.com> Authored: Fri Jun 29 14:12:31 2018 -0700 Committer: Hao Hao <hao....@cloudera.com> Committed: Mon Jul 2 22:34:30 2018 +0000 ---------------------------------------------------------------------- src/kudu/tools/tool_action_hms.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/95182a6d/src/kudu/tools/tool_action_hms.cc ---------------------------------------------------------------------- diff --git a/src/kudu/tools/tool_action_hms.cc b/src/kudu/tools/tool_action_hms.cc index d0e3c4b..f06367b 100644 --- a/src/kudu/tools/tool_action_hms.cc +++ b/src/kudu/tools/tool_action_hms.cc @@ -158,20 +158,21 @@ Status AlterLegacyKuduTables(KuduClient* kudu_client, if (hms_table->parameters[HmsClient::kStorageHandlerKey] == HmsClient::kLegacyKuduStorageHandler) { string new_table_name = Substitute("$0.$1", hms_table->dbName, hms_table->tableName); - bool exist; - RETURN_NOT_OK(kudu_client->TableExists(new_table_name, &exist)); - if (!exist) { - // TODO(Hao): Use notification listener to avoid race conditions. - s = AlterKuduTableOnly(kudu_client, table_name, new_table_name).AndThen([&] { - return hms_catalog->UpgradeLegacyImpalaTable(kudu_table->id(), - hms_table->dbName, hms_table->tableName, - client::SchemaFromKuduSchema(kudu_table->schema())); - }); - } else { - LOG(WARNING) << Substitute("Failed to upgrade legacy Impala table '$0.$1' " - "(Kudu table name: $2), because a Kudu table with " - "name '$0.$1' already exists'.", hms_table->dbName, - hms_table->tableName, table_name); + // Hive-compatible table name implies the table has been upgraded previously and + // then downgraded. In this case, we only upgrade the legacy Impala table. + if (table_name != new_table_name) { + s = AlterKuduTableOnly(kudu_client, table_name, new_table_name); + if (s.IsAlreadyPresent()) { + s = s.CloneAndPrepend(Substitute("Failed to upgrade legacy Impala table '$0.$1' " + "(Kudu table name: $2), because a Kudu table with " + "name '$0.$1' already exists'.", hms_table->dbName, + hms_table->tableName, table_name)); + } + } + if (s.ok()) { + s = hms_catalog->UpgradeLegacyImpalaTable( + kudu_table->id(), hms_table->dbName, hms_table->tableName, + client::SchemaFromKuduSchema(kudu_table->schema())); } } } else {