floraison / fugit

time tools (cron, parsing, durations, ...) for Ruby, rufus-scheduler, and flor
MIT License
353 stars 29 forks source link

cron #next_time loop breaker issue #60

Closed Ggallardoh closed 2 years ago

Ggallardoh commented 2 years ago

Issue description

A clear and concise description of what the issue is. (There is an example of a carefully filled issue at https://github.com/floraison/fugit/issues/18)

How to reproduce

The simplest piece of code that reproduces the issue, for example:

heroku local

Or else, please describe carefully what to do to see a live example of the issue.

Error and error backtrace (if any)

(This should look like:

/home/ggallardo/.rvm/gems/ruby-3.0.2/bin/sidekiq:23:in `load'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/bin/sidekiq:23:in `<main>'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/bin/ruby_executable_hooks:22:in `eval'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/bin/ruby_executable_hooks:22:in `<main>'
10:04:01 AM worker.1 |  2021-08-17T14:04:01.193Z pid=11350 tid=b42 WARN: RuntimeError: too many loops for "0 8 15 * *" #next_time, breaking, cron expression most likely invalid (Feb 30th like?), please fill an issue at https://git.io/fjJC9
10:04:01 AM worker.1 |  2021-08-17T14:04:01.193Z pid=11350 tid=b42 WARN: /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/fugit-1.5.0/lib/fugit/cron.rb:238:in `block in next_time'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/fugit-1.5.0/lib/fugit/cron.rb:236:in `loop'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/fugit-1.5.0/lib/fugit/cron.rb:236:in `next_time'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/rufus-scheduler-3.7.0/lib/rufus/scheduler/jobs_repeat.rb:329:in `set_next_time'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/rufus-scheduler-3.7.0/lib/rufus/scheduler/jobs_repeat.rb:281:in `initialize'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/rufus-scheduler-3.7.0/lib/rufus/scheduler.rb:711:in `new'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/rufus-scheduler-3.7.0/lib/rufus/scheduler.rb:711:in `do_schedule'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/rufus-scheduler-3.7.0/lib/rufus/scheduler.rb:226:in `cron'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler/scheduler.rb:244:in `new_job'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler/scheduler.rb:118:in `block in load_schedule_job'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler/scheduler.rb:111:in `each'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler/scheduler.rb:111:in `load_schedule_job'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler/scheduler.rb:89:in `block in load_schedule!'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler/scheduler.rb:87:in `each'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler/scheduler.rb:87:in `load_schedule!'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler/manager.rb:37:in `start'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-scheduler-3.1.0/lib/sidekiq-scheduler.rb:18:in `block (2 levels) in <main>'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-6.2.1/lib/sidekiq/util.rb:87:in `block in fire_event'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-6.2.1/lib/sidekiq/util.rb:86:in `each'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-6.2.1/lib/sidekiq/util.rb:86:in `fire_event'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-6.2.1/lib/sidekiq/cli.rb:92:in `run'
10:04:01 AM worker.1 |  /home/ggallardo/.rvm/gems/ruby-3.0.2/gems/sidekiq-6.2.1/bin/sidekiq:31:in `<top (required)>'

)

Expected behaviour

A clear and concise description of what you expected to happen.

Context

ggallardo@ggallardo-Z390-UD:~/tango/api$ uname -a
Linux ggallardo-Z390-UD 5.11.0-25-generic #27~20.04.1-Ubuntu SMP Tue Jul 13 17:41:23 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
ggallardo@ggallardo-Z390-UD:~/tango/api$ bundle exec ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
ggallardo@ggallardo-Z390-UD:~/tango/api$ bundle exec ruby -e "p [ :env_tz, ENV['TZ'] ]"
[:env_tz, nil]
ggallardo@ggallardo-Z390-UD:~/tango/api$ bundle exec ruby -r et-orbi -e "EtOrbi._make_info"
(secs:1629209891.538592,utc~:"2021-08-17 14:18:11.5385921001434326",ltz~:"-04")
(etz:nil,tnz:"-04",tziv:"2.0.4",tzidv:nil,rv:"3.0.2",rp:"x86_64-linux",win:false,rorv:nil,astz:nil,eov:"1.2.4",eotnz:#<TZInfo::DataTimezone: America/Santiago>,eotnfz:"-0400",eotlzn:"America/Santiago",eotnfZ:"-04",debian:"America/Santiago",centos:nil,osx:"America/Santiago")
ggallardo@ggallardo-Z390-UD:~/tango/api$ bundle exec ruby -r fugit -e "p Fugit::VERSION"
"1.5.0"
ggallardo@ggallardo-Z390-UD:~/tango/api$ bundle exec ruby -e "p [ :now, Time.now, :zone, Time.now.zone ]
> 

Additional context

Add any other context about the problem here.

jmettraux commented 2 years ago

I can reproduce the issue as well.

234143 _ yawara o ~/w/fugit (master|*) > chruby 2.7
ruby set to /home/jmettraux/.rubies/ruby-2.7.1/
234146 _ yawara o ~/w/fugit (master|*) > bxr t.rb
#<EtOrbi::EoTime:0x0000064ddd4d4578 @seconds=1631660400.0, @zone=#<TZInfo::DataTimezone: Asia/Tokyo>, @time=nil>
"2021-09-15 08:00:00 +0900"
234157 _ yawara o ~/w/fugit (master|*) >
234159 _ yawara o ~/w/fugit (master|*) >
234159 _ yawara o ~/w/fugit (master|*) > export TZ="America/Santiago"
104204 _ yawara o ~/w/fugit (master|*) > bxr t.rb
Traceback (most recent call last):
        3: from t.rb:5:in `<main>'
        2: from /home/jmettraux/w/fugit/lib/fugit/cron.rb:236:in `next_time'
        1: from /home/jmettraux/w/fugit/lib/fugit/cron.rb:236:in `loop'
/home/jmettraux/w/fugit/lib/fugit/cron.rb:238:in `block in next_time': too many loops for "0 8 15 * *" #next_time, breaking, cron expression most likely invalid (Feb 30th like?), please fill an issue at https://git.io/fjJC9 (RuntimeError)
104207 _ yawara o ~/w/fugit (master|*) [1] > rv
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-openbsd6.7]
104211 _ yawara o ~/w/fugit (master|*) > uname -a
OpenBSD yawara 6.9 GENERIC.MP#4 amd64
104307 _ yawara o ~/w/fugit (master|*) > bundle list
Gems included by the bundle:
  * chronic (0.10.2)
  * concurrent-ruby (1.1.9)
  * diff-lcs (1.4.4)
  * et-orbi (1.2.4)
  * fugit (1.5.0)
  * raabro (1.4.0)
  * rspec (3.10.0)
  * rspec-core (3.10.1)
  * rspec-expectations (3.10.1)
  * rspec-mocks (3.10.2)
  * rspec-support (3.10.2)
  * tzinfo (2.0.4)
Use `bundle info` to print more detailed information about a gem

It doesn't happen in the Tokyo timezone, but in the America/Santiago timezone. Ruby 2.7 or Ruby 3.0. Happens with fugit 1.5.0 and 1.4.5. Doesn't happen with fugit 1.3.9 (see fugit/versions).

@Ggallardoh Thanks for reporting that. I will fix that tomorrow, hopefully. For now you could use fugit 1.3.9 or switch from "0 8 15 * *" to "0 11 15 * * UTC" temporarily.

Ggallardoh commented 2 years ago

We will make the changes you suggested momentarily, and we will be looking forward to the changes. Thank you!

jmettraux commented 2 years ago

I will release 1.5.1 soon. If there is anything wrong with it, please tell me.

jmettraux commented 2 years ago

fugit 1.5.1 released https://rubygems.org/gems/fugit/versions/1.5.1

jmettraux commented 2 years ago

@javix70 @Ggallardoh @BMunozKlerman Please remember that emojis trigger no notifications for project maintainers. Please consider starring this project if you appreciate my work and my help.

jmettraux commented 2 years ago

Thanks a lot!!!