influxdata / influxdata/influxdb
+1 second is added when saving
- Dominant language
- Rust
- Stars
- 31.7k
- Forks
- 3.7k
- Avg merge
- 13h 37m
- Merged PRs (30d)
- 8
Description
I already incorrectly created the [issue on the client library which I'm using](https://github.com/influxdata/influxdb-client-csharp/issues/575), but according to everything, it is a bug of InfluxDb.
The problem is that even if I send save request with a valid timestamp (seconds precision), for some reason the record is always saved with 1 second added.
Ticks before save: 638270928000000000 (2023/08/08 12:00:00)
It's also correctly converted into unix timestamp: 1691496000 (2023/08/08 12:00:00)
Ticks when query record: 638270928010000000 (2023/08/08 12:00:01)
It's also same wrong time in InfluxDb Data Explorer.

__Steps to reproduce:__
curl -X POST "http://localhost:8086/api/v2/write?org=organization&bucket=test-bucket&precision=s"
--header "Authorization: Token my-super-secret-auth-token"
--header "Content-Type: text/plain"
--data-binary "measurement_curl,field_name=value value=42i 1691496000"
__Expected behavior:__
Record is saved with DateTime 2023/08/08 12:00:00
__Actual behavior:__
Record is saved with DateTime 2023/08/08 12:00:01
__Specifications:__
- InfluxDB Version: 2.7.1
- Platform: .NET 7, InfluxDb running in docker, MacOS
__Environment info:__
docker-compose:
influxdb:
image: influxdb:2.7.1
container_name: influxdb
hostname: host_influx_db
volumes:
- influx_db:/var/lib/influxdb
ports:
- 8086:8086
restart: unless-stopped
environment:
- DOCKER_INFLUXDB_INIT_MODE=setup
- DOCKER_INFLUXDB_INIT_USERNAME=admin
- DOCKER_INFLUXDB_INIT_PASSWORD=adminadmin
- DOCKER_INFLUXDB_INIT_ORG=organization
- DOCKER_INFLUXDB_INIT_BUCKET=test-bucket
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-auth-token
__Workaround:__
DateTime with .AddMicroseconds(-1) (2023/08/08 11:59:59) correctly saves it as 2023/08/08 12:00:00
Contributor guide
Research direction
Run the supplied curl request against the stated InfluxDB 2.7.1 setup and compare the stored timestamp with 1691496000 at second precision. Trace the write API's timestamp handling to determine where the extra second appears. Done means a valid second-precision timestamp is stored and queried as 2023/08/08 12:00:00 without the workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100