clock time issue

Hi,

We have an issue du to clock drift on our machine that we used for our ruby backend. Our scheduled task start 0.01s too early sometime.

I try this ruby sample :

require 'concurrent-ruby'
require 'time'
require 'fugit'

class TestFugit

  def initialize
    @fugit = Fugit.parse('*/1 * * * *')
  end

  def create_task
    cron_at = @fugit.next_time.to_t
    puts Time.now.to_f
    delay = [(cron_at - Time.now).to_f, 0].max
    puts "delay = #{delay}"

    future = Concurrent::ScheduledTask.new(delay, args: [self]) do |tf|
      tf.create_task
      puts "Exec task #{Time.now.to_f}"
    end

    future.execute
  end
end
puts "ici"
TestFugit.new.create_task

sleep 1000

and having some unexpected behaviors :

1731617520.0011902
delay = 59.998755028
Exec task 1731617520.001527
1731617579.9996374
delay = 0.000323485
Exec task 1731617579.9999614
1731617580.0002928
delay = 59.999671595
Exec task 1731617580.0005002

delay = 0.000323485 is unexpected.
I didn’t have the issue on my mac, in docker on my mac, in docker on aws ec2

when I launch this command :

root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:16:30.132940 (+0000) -0.000796 +/- 0.054938 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:16:35.157688 (+0000) -0.001291 +/- 0.055948 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:16:38.405198 (+0000) -0.001305 +/- 0.055983 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:16:40.305173 (+0000) +0.047853 +/- 0.103732 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:16:42.367457 (+0000) -0.000356 +/- 0.055291 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:16:44.730649 (+0000) +0.049826 +/- 0.107177 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:16:49.232577 (+0000) +0.048609 +/- 0.105800 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:17:38.469664 (+0000) -0.003512 +/- 0.056417 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:17:40.440096 (+0000) +0.046477 +/- 0.104049 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:17:43.743169 (+0000) +0.105781 +/- 0.162891 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:17:45.647641 (+0000) -0.000898 +/- 0.056586 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap
root@5683326dad4d08:/rails# ntpdate -q 1.debian.pool.ntp.org
2024-11-14 21:17:49.360629 (+0000) +0.000004 +/- 0.055826 1.debian.pool.ntp.org 99.119.214.210 s1 no-leap

we can see some drift

Do you have a solution to fix this issue ?

Thanks.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.