Skip to content

Commit

Permalink
[fix](group commit) group commit show error url (apache#38292)
Browse files Browse the repository at this point in the history
## Proposed changes
 
`insert into` in group commit should show error url if some rows are
invalid.
  • Loading branch information
mymeiyi authored Jul 24, 2024
1 parent ee0b4c6 commit 8602a4a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions be/src/service/internal_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2051,6 +2051,10 @@ void PInternalService::group_commit_insert(google::protobuf::RpcController* cont
response->set_loaded_rows(state->num_rows_load_success());
response->set_filtered_rows(state->num_rows_load_filtered());
status->to_protobuf(response->mutable_status());
if (!state->get_error_log_file_path().empty()) {
response->set_error_url(
to_load_error_http_path(state->get_error_log_file_path()));
}
_exec_env->new_load_stream_mgr()->remove(load_id);
});
} catch (const Exception& e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2369,11 +2369,17 @@ private void handleInsertStmt() throws Exception {
errMsg = "group commit insert failed. db_id: " + dbId + ", table_id: " + tableId
+ ", query_id: " + DebugUtil.printId(context.queryId()) + ", backend_id: "
+ groupCommitPlanner.getBackend().getId() + ", status: " + response.getStatus();
if (response.hasErrorUrl()) {
errMsg += ", error url: " + response.getErrorUrl();
}
}
} else if (code != TStatusCode.OK) {
errMsg = "group commit insert failed. db_id: " + dbId + ", table_id: " + tableId + ", query_id: "
+ DebugUtil.printId(context.queryId()) + ", backend_id: " + groupCommitPlanner.getBackend()
.getId() + ", status: " + response.getStatus();
if (response.hasErrorUrl()) {
errMsg += ", error url: " + response.getErrorUrl();
}
ErrorReport.reportDdlException(errMsg, ErrorCode.ERR_FAILED_WHEN_INSERT);
}
label = response.getLabel();
Expand Down
1 change: 1 addition & 0 deletions gensrc/proto/internal_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ message PGroupCommitInsertResponse {
optional int64 txn_id = 3;
optional int64 loaded_rows = 4;
optional int64 filtered_rows = 5;
optional string error_url = 6;
}

message POpenLoadStreamRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ suite("insert_group_commit_into") {
sql "set enable_insert_strict=false"
group_commit_insert """ insert into ${table} values (1, 'a', 10),(5, 'q', 50),(101, 'a', 100); """, 2
sql "set enable_insert_strict=true"
try {
sql """ insert into ${table} values (102, 'a', 100); """
assertTrue(false, "insert should fail")
} catch (Exception e) {
logger.info("error: " + e.getMessage())
assertTrue(e.getMessage().contains("url:"))
}
sql """ alter table ${table} ADD ROLLUP r1(name, score); """
group_commit_insert_with_retry """ insert into ${table}(id, name) values(2, 'b'); """, 1
group_commit_insert_with_retry """ insert into ${table}(id) values(6); """, 1
Expand Down

0 comments on commit 8602a4a

Please sign in to comment.