tokio-cron-scheduler icon indicating copy to clipboard operation
tokio-cron-scheduler copied to clipboard

`Tick send error SendError(true)` after a while

Open jukanntenn opened this issue 1 year ago • 1 comments

I have an application using tokio-cron-scheduler. However, after the application starting and running for a while, the cron scheduler no longer work and print Tick send error SendError(true) to the console every 500ms.

I did some investigation on it, here is the source code where produce the error:

loop {
        if let Err(e) = tx.send(true) {
            let shutdown = { *(shutdown.read().await) };
            if shutdown {
                return;
            }
            error!("Tick send error {:?}", e);
        }
        tokio::time::sleep(Duration::from_millis(500)).await;
    }

tokio::sync::broadcast::Sender documentation says

An unsuccessful send would be one where all associated [Receiver] handles have already been dropped.

I have no idea why this occurs. Would you please provide some hints or suggestions for how to debug this error? Since my application is a little complex, so I'm sorry that I can't provide a minimal example to reproduce the issue.

Thanks a lot!

jukanntenn avatar Oct 22 '22 07:10 jukanntenn

Hi @jukanntenn Yes, an MPSC receiver channel was dropped somewhere causing this. Can be that your job scheduler variable ran out of scope. It is a bit hard to debug without the code though.

mvniekerk avatar Oct 23 '22 04:10 mvniekerk