delay-timer icon indicating copy to clipboard operation
delay-timer copied to clipboard

an error occurls when use delay-timer 0.10.0

Open elderbig opened this issue 4 years ago • 3 comments

report an error when use delay-timer 0.10.0 I try run 1000 jobs in my program,ceveral minitue later,when process running, some error appeard

2021-11-22T08:56:18.222587252+08:00 - INFO - src/main.rs -line=>29 - dt_test - ==== All job is be init! ====
2021-11-22T08:56:30.354993232+08:00 - ERROR - /home/test/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/delay_timer-0.10.0/src/timer/event_handle.rs -line=>199 - delay_timer::timer::event_handle - Fn : `quit_one_task_handler`, No task-handle-index found (task-id: 453 , record-id: 6868351392860475493)
2021-11-22T08:56:30.375546872+08:00 - ERROR - /home/test/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/delay_timer-0.10.0/src/timer/event_handle.rs -line=>199 - delay_timer::timer::event_handle - Fn : `quit_one_task_handler`, No task-handle-index found (task-id: 78 , record-id: 6868351392860475444)
2021-11-22T08:56:30.380463067+08:00 - ERROR - /home/test/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/delay_timer-0.10.0/src/timer/event_handle.rs -line=>199 - delay_timer::timer::event_handle - Fn : `quit_one_task_handler`, No task-handle-index found (task-id: 561 , record-id: 6868351392860475452)
2021-11-22T08:56:30.386620506+08:00 - ERROR - /home/test/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/delay_timer-0.10.0/src/timer/event_handle.rs -line=>199 - delay_timer::timer::event_handle - Fn : `quit_one_task_handler`, No task-handle-index found (task-id: 502 , record-id: 6868351392860475446)
2021-11-22T08:56:30.394059243+08:00 - ERROR - /home/test/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/delay_timer-0.10.0/src/timer/event_handle.rs -line=>199 - delay_timer::timer::event_handle - Fn : `quit_one_task_handler`, No task-handle-index found (task-id: 37 , record-id: 6868351392860475469)
2021-11-22T08:56:30.417319172+08:00 - ERROR - /home/test/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/delay_timer-0.10.0/src/timer/event_handle.rs -line=>199 - delay_timer::timer::event_handle - Fn : `quit_one_task_handler`, No task-handle-index found (task-id: 164 , record-id: 6868351392860475457)

After this error,the program is still running,I can not know if there is some effection. my program

#[async_std::main]
async fn main() -> Result<()>{
    log4rs::init_file("conf/log4rs.yaml", Default::default()).unwrap();
    info!("begin");
    let delay_timer = DelayTimerBuilder::default().build();
    for i in 0..1000{
        let r = build_task_async_execute_process(i);
        match r {
            Ok(task) => {
                let r = delay_timer.add_task(task);
                match r {
                    Ok(_) => info!("init task id = [{}]", i),
                    Err(e) => info!("{}", e)
                } 
            },
            Err(e)=> info!("{}", e)
        }
    }
    info!("==== All job is be init! ====");
    thread::sleep(Duration::from_secs(3600*6));
    Ok(delay_timer.stop_delay_timer()?)
}

fn build_task_async_execute_process(task_id:u64) -> Result<Task, TaskError> {
    let mut task_builder = TaskBuilder::default();
    let cmd_string = String::from("sh tester/test_script.sh");
    info!("cmd_string = [{}]", &cmd_string);
    let body = dt_functions::unblock_process_task_fn(cmd_string);
    task_builder
        .set_frequency_repeated_by_cron_str("* * * * * *".into())
        .set_task_id(task_id)
        .set_maximum_running_time(10)
        .set_maximum_parallel_runnable_num(1)
        .spawn(body)
}

also can see at my test project https://github.com/elderbig/delay_timer-test

relevant issue #28

elderbig avatar Nov 22 '21 02:11 elderbig

Friend, this problem is because each task execution has a timeout tracker, the error report shows that the task has been executed, but the timeout tracker is slow to respond, thinking that the task has timed out to cancel the task.

Are you using debug mode to compile the program?

ps: (debug program generated code optimization efficiency is not enough to run slow will have this happen)

BinChengZhao avatar Nov 22 '21 03:11 BinChengZhao

Both debug and release can meet this error report, I did not find this report may be because I did not init log system that time,I think. this is the rust toolchain I used

rustup home:  /home/test/.rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-2021-09-10-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.56.1 (59eed8a2a 2021-11-01)

elderbig avatar Nov 22 '21 11:11 elderbig

Ok friend, I have received your feedback and started working on optimizing this redundant error message.

You can use the current version and don't worry about it.

Because this error message has absolutely no effect on the running program, it's just the program handling redundant events.

BinChengZhao avatar Nov 22 '21 11:11 BinChengZhao