From beb02faef3c370565cfbc60e0baee6c409a6a666 Mon Sep 17 00:00:00 2001 From: Yukang-Lian Date: Wed, 21 Aug 2024 19:58:35 +0800 Subject: [PATCH 1/5] 1 --- .../apache/doris/httpv2/rest/LoadAction.java | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java index c2d50460ea4954..e33b52f91aa780 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java +++ b/fe/fe-core/src/main/java/org/apache/doris/httpv2/rest/LoadAction.java @@ -294,17 +294,20 @@ private Object executeWithoutPassword(HttpServletRequest request, return new RestBaseResult(e.getMessage()); } } else { - Optional database = Env.getCurrentEnv().getCurrentCatalog().getDb(dbName); - if (!database.isPresent()) { - return new RestBaseResult("Database not founded."); + long tableId = -1; + if (groupCommit) { + Optional database = Env.getCurrentEnv().getCurrentCatalog().getDb(dbName); + if (!database.isPresent()) { + return new RestBaseResult("Database not found."); + } + + Optional olapTable = ((Database) database.get()).getTable(tableName); + if (!olapTable.isPresent()) { + return new RestBaseResult("OlapTable not found."); + } + + tableId = ((OlapTable) olapTable.get()).getId(); } - - Optional olapTable = ((Database) database.get()).getTable(tableName); - if (!olapTable.isPresent()) { - return new RestBaseResult("OlapTable not founded."); - } - - long tableId = ((OlapTable) olapTable.get()).getId(); redirectAddr = selectRedirectBackend(request, groupCommit, tableId); } @@ -384,6 +387,9 @@ private TNetworkAddress selectRedirectBackend(HttpServletRequest request, boolea } return selectCloudRedirectBackend(cloudClusterName, request, groupCommit); } else { + if (groupCommit && tableId == -1) { + throw new LoadException("Group commit table id wrong."); + } return selectLocalRedirectBackend(groupCommit, request, tableId); } } From 72374d611cd2bd992dd87b57a9373dc49a24f99f Mon Sep 17 00:00:00 2001 From: Yukang-Lian Date: Thu, 22 Aug 2024 16:08:45 +0800 Subject: [PATCH 2/5] 2 --- ...eam_load_with_nonexist_db_and_table.groovy | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy diff --git a/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy new file mode 100644 index 00000000000000..da0249082ab0d3 --- /dev/null +++ b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy @@ -0,0 +1,38 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_group_commit_stream_load_with_nonexist_db_and_table") { + def tableName = "test_group_commit_stream_load_with_nonexist_db_and_table" + + try { + streamLoad { + table "${tableName}" + + set 'column_separator', ',' + set 'group_commit', 'async_mode' + set 'columns', 'id, name' + file "test_stream_load1.csv" + unset 'label' + + time 10000 + } + } catch (Exception e) { + logger.info("failed: " + e.getMessage()) + } finally { + + } +} From 85e79aa6b8d6838511783de92c7b1f711ffa1bb5 Mon Sep 17 00:00:00 2001 From: Yukang-Lian Date: Sat, 24 Aug 2024 16:51:20 +0800 Subject: [PATCH 3/5] 3 --- ...eam_load_with_nonexist_db_and_table.groovy | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy index da0249082ab0d3..3992251fb0acb5 100644 --- a/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy +++ b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy @@ -17,21 +17,24 @@ suite("test_group_commit_stream_load_with_nonexist_db_and_table") { def tableName = "test_group_commit_stream_load_with_nonexist_db_and_table" + sql "drop database ${tableName}" + sql "create database ${tableName}" try { - streamLoad { - table "${tableName}" + def command = "curl --location-trusted -u ${context.config.feHttpUser}:${context.config.feHttpPassword}" + + " -H group_commit:sync_mode" + + " -H column_separator:," + + " -T ${context.config.dataPath}/load_p0/stream_load/test_stream_load1.csv" + + " http://${context.config.feHttpAddress}/api/${tableName}/${tableName}/_stream_load" + log.info("stream load command: ${command}") - set 'column_separator', ',' - set 'group_commit', 'async_mode' - set 'columns', 'id, name' - file "test_stream_load1.csv" - unset 'label' - - time 10000 - } + def process = command.execute() + code = process.waitFor() + out = process.text + log.info("stream load result: ${out}".toString()) } catch (Exception e) { logger.info("failed: " + e.getMessage()) + assertTrue(e.getMessage().contains(table not found)) } finally { } From af50ccc315b292028794a81d18ddaa1254351403 Mon Sep 17 00:00:00 2001 From: Yukang-Lian Date: Sat, 24 Aug 2024 20:22:53 +0800 Subject: [PATCH 4/5] 4 --- ..._group_commit_stream_load_with_nonexist_db_and_table.groovy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy index 3992251fb0acb5..efc24fea616d33 100644 --- a/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy +++ b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy @@ -17,8 +17,7 @@ suite("test_group_commit_stream_load_with_nonexist_db_and_table") { def tableName = "test_group_commit_stream_load_with_nonexist_db_and_table" - sql "drop database ${tableName}" - sql "create database ${tableName}" + sql "create database if not exists ${tableName}" try { def command = "curl --location-trusted -u ${context.config.feHttpUser}:${context.config.feHttpPassword}" + From 66698bd9ba346686e7241eca861100c3628abafa Mon Sep 17 00:00:00 2001 From: Yukang-Lian Date: Mon, 26 Aug 2024 15:01:11 +0800 Subject: [PATCH 5/5] 5 --- ...roup_commit_stream_load_with_nonexist_db_and_table.groovy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy index efc24fea616d33..ba806967bf79b1 100644 --- a/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy +++ b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy @@ -30,10 +30,11 @@ suite("test_group_commit_stream_load_with_nonexist_db_and_table") { def process = command.execute() code = process.waitFor() out = process.text - log.info("stream load result: ${out}".toString()) + log.info("stream lad result: ${out}".toString()) + assertTrue(out.toString().contains("table not found")) } catch (Exception e) { logger.info("failed: " + e.getMessage()) - assertTrue(e.getMessage().contains(table not found)) + assertTrue(false) } finally { }