influxdata / influxdata/influxdb

Cron-based task doesn't run at system time

Open
#20,922 1 comment 5 reactions 0 assignees View on GitHub
area/2.x area/tasks
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

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:__

* System info: Linux 4.19.104-microsoft-standard x86_64
* InfluxDB version: InfluxDB 2.0.4 (git: 4e7a59bb9a) build_date: 2021-02-08T17:47:02Z
* Docker Version: 3.2.1 (61626), Engine 20.10.5.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the documented Docker setup, Europe/Madrid timezone, and cron option, then trace the task scheduler's first execution and timezone initialization. Done means the first and subsequent executions both occur at the configured local system time rather than the first run using UTC.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, linux
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.