influxdata / influxdb

Scalable datastore for metrics, events, and real-time analytics
https://influxdata.com
Apache License 2.0
28.95k stars 3.56k forks source link

Cron-based task doesn't run at system time #20922

Open JFCmedlinetec opened 3 years ago

JFCmedlinetec commented 3 years ago

When I schedule a cron-based task in InfluxDB it does not run at system time the first time that it has to be executed (as per documentation says the cron option is based on system time). The first time it runs in UTC time. From the second time onwards it runs with the same hour as the system time how it's supposed to always happen.

We use Docker in my company so InfluxDB live within a container with Debian (with Alpine Linux also fails).

Minimal actions needed to reproduce the behavior:

  1. docker pull influxdb
  2. docker run -p 8086:8086 --name influxdb --privileged influxdb
  3. Inside container: ln -sf /usr/share/zoneinfo/Europe/Madrid /etc/localtime
  4. Initial Setup influxDB GUI with username, password, org and initial bucket
  5. Create the following task: option task = {name: "Task1", cron: "0 14 * * *"} option v1 = {timeRangeStart: -7h, timeRangeStop: now()} data = from(bucket: "initialBucket") |> range(start: v1.timeRangeStart, stop: v1.timeRangeStop) |> filter(fn: (r) => (r._measurement == "something")) (No matter that the task doesn't make sense, it's just for the purpose of checking its execution)

My hardware clock and the system time looks like this in the container: /etc # hwclock 2021-03-10 18:06:31.945795+01:00 /etc # date Wed Mar 10 18:06:34 CET 2021

I think the time zone is as it should be. My time zone is "Europe/Madrid", +01:00 right now (+02:00 in summer with DST).

The task should run at 14:00 local time (system time), however the first time it will run at 14:00 UTC (15:00 local time). From the second run the execution time is correct (14:00 local time).

I've researched and read everywhere and I'm not able to find a reason or if it's happening to someone else.

Environment info:

vkhemani commented 2 years ago

Hi, i am facing the same problem. Any solution yet?