Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bobhan1 committed Jul 16, 2024
1 parent 27a8702 commit 57aed73
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 28 deletions.
6 changes: 5 additions & 1 deletion be/src/common/status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ void Status::to_thrift(TStatus* s) const {
// DCHECK(_code > 0)
// << "The error code has to > 0 because TStatusCode need it > 0, it's actual value is "
// << _code;
s->status_code = (int16_t)_code > 0 ? (TStatusCode::type)_code : TStatusCode::INTERNAL_ERROR;
s->status_code = (int16_t)_code > 0 ? (TStatusCode::type)_code
: ((_code == ErrorCode::DELETE_INVALID_CONDITION ||
_code == ErrorCode::DELETE_INVALID_PARAMETERS)
? TStatusCode::INVALID_ARGUMENT
: TStatusCode::INTERNAL_ERROR);
s->error_msgs.push_back(fmt::format("({})[{}]{}", BackendOptions::get_localhost(),
code_as_string(), _err_msg ? _err_msg->_msg : ""));
s->__isset.error_msgs = true;
Expand Down
31 changes: 13 additions & 18 deletions be/src/olap/delete_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ Status DeleteHandler::generate_delete_predicate(const TabletSchema& schema,
})
if (conditions.empty()) {
return Status::Error<DELETE_INVALID_PARAMETERS>(
"DELETE_INVALID_PARAMETERS: invalid parameters for store_cond. condition_size={}",
conditions.size());
"invalid parameters for store_cond. condition_size={}", conditions.size());
}

// Check whether the delete condition meets the requirements
Expand Down Expand Up @@ -129,8 +128,7 @@ Status DeleteHandler::generate_delete_predicate(const TabletSchema& schema,
LOG(WARNING) << "failed to parse condition_str, condtion="
<< ThriftDebugString(condition);
return Status::Error<DELETE_INVALID_CONDITION>(
"DELETE_INVALID_CONDITION: failed to parse condition_str, condtion={}",
ThriftDebugString(condition));
"failed to parse condition_str, condtion={}", ThriftDebugString(condition));
}
VLOG_NOTICE << __PRETTY_FUNCTION__ << " condition_str: " << condition_str;
del_pred->add_sub_predicates(condition_str);
Expand Down Expand Up @@ -237,8 +235,8 @@ Status DeleteHandler::check_condition_valid(const TabletSchema& schema, const TC
// Check whether the column exists
int32_t field_index = schema.field_index(cond.column_name);
if (field_index < 0) {
return Status::Error<DELETE_INVALID_CONDITION>(
"DELETE_INVALID_CONDITION: field is not existent. [field_index={}]", field_index);
return Status::Error<DELETE_INVALID_CONDITION>("field is not existent. [field_index={}]",
field_index);
}

// Delete condition should only applied on key columns or duplicate key table, and
Expand All @@ -247,24 +245,21 @@ Status DeleteHandler::check_condition_valid(const TabletSchema& schema, const TC

if (column.type() == FieldType::OLAP_FIELD_TYPE_DOUBLE ||
column.type() == FieldType::OLAP_FIELD_TYPE_FLOAT) {
return Status::Error<DELETE_INVALID_CONDITION>(
"DELETE_INVALID_CONDITION: data type is float or double.");
return Status::Error<DELETE_INVALID_CONDITION>("data type is float or double.");
}

// Check operator and operands size are matched.
if ("*=" != cond.condition_op && "!*=" != cond.condition_op &&
cond.condition_values.size() != 1) {
return Status::Error<DELETE_INVALID_CONDITION>(
"DELETE_INVALID_CONDITION: invalid condition value size. [size={}]",
cond.condition_values.size());
return Status::Error<DELETE_INVALID_CONDITION>("invalid condition value size. [size={}]",
cond.condition_values.size());
}

// Check each operand is valid
for (const auto& condition_value : cond.condition_values) {
if (!is_condition_value_valid(column, cond.condition_op, condition_value)) {
return Status::Error<DELETE_INVALID_CONDITION>(
"DELETE_INVALID_CONDITION: invalid condition value. [value={}]",
condition_value);
return Status::Error<DELETE_INVALID_CONDITION>("invalid condition value. [value={}]",
condition_value);
}
}

Expand All @@ -276,14 +271,14 @@ Status DeleteHandler::check_condition_valid(const TabletSchema& schema, const TC
}
if (schema.field_index(cond.column_unique_id) == -1) {
const auto& err_msg = fmt::format(
"DELETE_INVALID_CONDITION: column id does not exists in table={}, schema "
"column id does not exists in table={}, schema "
"version={},",
schema.table_id(), schema.schema_version());
return Status::Error<DELETE_INVALID_CONDITION>(err_msg);
}
if (!iequal(schema.column_by_uid(cond.column_unique_id).name(), cond.column_name)) {
const auto& err_msg = fmt::format(
"DELETE_INVALID_CONDITION: colum name={} does not belongs to column uid={}, which "
"colum name={} does not belongs to column uid={}, which "
"column name={}, "
"delete_cond.column_name ={}",
cond.column_name, cond.column_unique_id,
Expand All @@ -297,8 +292,8 @@ Status DeleteHandler::check_condition_valid(const TabletSchema& schema, const TC
Status DeleteHandler::parse_condition(const DeleteSubPredicatePB& sub_cond, TCondition* condition) {
if (!sub_cond.has_column_name() || !sub_cond.has_op() || !sub_cond.has_cond_value()) {
return Status::Error<DELETE_INVALID_PARAMETERS>(
"DELETE_INVALID_PARAMETERS: fail to parse condition. condition={} {} {}",
sub_cond.column_name(), sub_cond.op(), sub_cond.cond_value());
"fail to parse condition. condition={} {} {}", sub_cond.column_name(),
sub_cond.op(), sub_cond.cond_value());
}
if (sub_cond.has_column_unique_id()) {
condition->column_unique_id = sub_cond.column_unique_id();
Expand Down
15 changes: 6 additions & 9 deletions fe/fe-core/src/main/java/org/apache/doris/master/MasterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,12 @@ private void finishRealtimePush(AgentTask task, TFinishTaskRequest request) thro
if (pushTask.getPushType() == TPushType.DELETE) {
// we don't need to retry if the returned status code is DELETE_INVALID_CONDITION
// or DELETE_INVALID_PARAMETERS
// note that they will be converted to TStatusCode.INTERNAL_ERROR when being sent from be to fe
if (request.getTaskStatus().getStatusCode() == TStatusCode.INTERNAL_ERROR) {
String errMsg = request.getTaskStatus().getErrorMsgs().toString();
if (errMsg.contains("DELETE_INVALID_CONDITION") || errMsg.contains("DELETE_INVALID_CONDITION")) {
pushTask.countDownToZero(request.getTaskStatus().getStatusCode(),
task.getBackendId() + ": " + request.getTaskStatus().getErrorMsgs().toString());
AgentTaskQueue.removeTask(backendId, TTaskType.REALTIME_PUSH, signature);
LOG.warn("finish push replica error: {}", request.getTaskStatus().getErrorMsgs().toString());
}
// note that they will be converted to TStatusCode.INVALID_ARGUMENT when being sent from be to fe
if (request.getTaskStatus().getStatusCode() == TStatusCode.INVALID_ARGUMENT) {
pushTask.countDownToZero(request.getTaskStatus().getStatusCode(),
task.getBackendId() + ": " + request.getTaskStatus().getErrorMsgs().toString());
AgentTaskQueue.removeTask(backendId, TTaskType.REALTIME_PUSH, signature);
LOG.warn("finish push replica error: {}", request.getTaskStatus().getErrorMsgs().toString());
}
}
return;
Expand Down

0 comments on commit 57aed73

Please sign in to comment.