shunfei/cronsun

获取任务锁超时时间的逻辑有点看不懂

lijr20171011 opened this issue · 1 comments

Please answer these questions before submitting your issue. Thanks!
在你提交 issue 前,请先回答以下问题,谢谢!

  1. What version of Go and cronsun version are you using?
    你用的是哪个版本的 Go 和 哪个版本的 cronsun?
    "v0.3.5 (build go1.12)"

  2. What operating system and processor architecture are you using (go env)?
    你用的是哪个操作系统,什么架构的?
    linux amd64

  3. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    你做了什么,遇到了什么问题?尽可能描述清楚问题,最好把操作步骤写下来,按这些步骤操作后能重现你的问题。
    查看源码时,不知道获取单机单进程任务锁的过期时间为什么这么处理
    文件:cronsun/job.go
    image

  4. What did you expect to see?
    你期望得到什么样的结果?
    希望有人能帮我解惑

  5. What did you see instead?
    现在你得到的结果是什么样的?
    猜测c.Job.AvgTime/1e3-cost*1e3的原意可能是想取余,不知道我想的对不对。后面的还是没看懂

我也对这个ttl - cost感到非常迷惑,并且我还猜测,如果任务执行时node与etcd断开了连接,甚至有可能无法保证是单进程运行的,毕竟etcd的锁会超时释放,也不能保证现有进程的本次所需执行时间