Skip to content

[Bug] query_time based workload policy not work due to wrong finish_time_ #60454

@wenzhenghu

Description

@wenzhenghu

Search before asking

  • I had searched in the issues and found no similar issues.

Version

branch 4.0 and master

What's Wrong?

void finish() {
    if (!is_finished_) {
        is_finished_ = true;
        finish_time_ = MonotonicMillis();
    }
    finish_impl();
}

finish_time_ is updated in finish(), but before that , it will be used in

   int64_t running_time() const { return finish_time() - start_time(); }
   int64_t finish_time() const { return finish_time_; } // finish_time_ inited value is  0

when query is running , it will be checked if match the workload policy by

bool WorkloadSchedPolicy::is_match(WorkloadAction::RuntimeContext* action_runtime_ctx) const {
...
        switch (cond->get_workload_metric_type()) {
        case WorkloadMetricType::QUERY_TIME: {
            val = std::to_string(
                    action_runtime_ctx->resource_ctx->task_controller()->running_time());
            break;
        }
...
        if (!cond->eval(val)) {
            return false;
        } 
...
}

bool WorkloadConditionQueryTime::eval(std::string str_val) {
    int64_t query_time_args = std::stol(str_val);
    return WorkloadCompareUtils::compare_signed_integer(_op, query_time_args, _query_time);
}

What You Expected?

fix it

How to Reproduce?

create a workload policy like this

create workload Policy test_cancel_Policy
Conditions(query_time > 3000)
Actions(cancel_query) 
properties('enabled'='true'); 

and run tpcds/tpch100, query will not killed by query time exceed. what expectd is
cancelled by workload policy: test_cancel_3s_query, id:1770025926146, query_time:3491(3000)

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions