This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new d91a6c98685 [Fix](group commit) Fix table not found fault when disable
group commit (#39731)
d91a6c98685 is described below
commit d91a6c98685884571fcec64737e33efce5043041
Author: abmdocrt <[email protected]>
AuthorDate: Wed Aug 28 23:11:51 2024 +0800
[Fix](group commit) Fix table not found fault when disable group commit
(#39731)
## Proposed changes
<!--Describe your changes.-->
selectRedirectBackend param table id is only needed by group commit. In
non group commit mode, if table id is null, we need to ignore it.
---
.../org/apache/doris/httpv2/rest/LoadAction.java | 24 ++++++++-----
...t_stream_load_with_nonexist_db_and_table.groovy | 41 ++++++++++++++++++++++
2 files changed, 56 insertions(+), 9 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 b0a714da149..c9681eb7849 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
@@ -313,17 +313,20 @@ public class LoadAction extends RestBaseController {
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 founded.");
- }
+ Optional<?> olapTable = ((Database)
database.get()).getTable(tableName);
+ if (!olapTable.isPresent()) {
+ return new RestBaseResult("OlapTable not found.");
+ }
- long tableId = ((OlapTable) olapTable.get()).getId();
+ tableId = ((OlapTable) olapTable.get()).getId();
+ }
redirectAddr = selectRedirectBackend(request, groupCommit,
tableId);
}
@@ -403,6 +406,9 @@ public class LoadAction extends RestBaseController {
}
return selectCloudRedirectBackend(cloudClusterName, request,
groupCommit, tableId);
} else {
+ if (groupCommit && tableId == -1) {
+ throw new LoadException("Group commit table id wrong.");
+ }
return selectLocalRedirectBackend(groupCommit, request, tableId);
}
}
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 00000000000..ba806967bf7
--- /dev/null
+++
b/regression-test/suites/load_p0/stream_load/test_group_commit_stream_load_with_nonexist_db_and_table.groovy
@@ -0,0 +1,41 @@
+// 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"
+ sql "create database if not exists ${tableName}"
+
+ try {
+ 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}")
+
+ def process = command.execute()
+ code = process.waitFor()
+ out = process.text
+ log.info("stream lad result: ${out}".toString())
+ assertTrue(out.toString().contains("table not found"))
+ } catch (Exception e) {
+ logger.info("failed: " + e.getMessage())
+ assertTrue(false)
+ } finally {
+
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]