VictoriaMetrics icon indicating copy to clipboard operation
VictoriaMetrics copied to clipboard

Error while inserting data more then 2 days in future.

Open prdatur opened this issue 5 years ago • 9 comments

Describe the bug Writing data with future day, produces: 2020-10-11T22:52:07.001Z error VictoriaMetrics/lib/storage/storage.go:1237 warn occurred during rows addition: cannot insert row with too big timestamp 1893452400000 exceeding the current time; maximum allowd timestamp is 1602629526000; propbably you need updating -retentionPeriod command-line flag

To Reproduce Insert data with a future day (more then +2 days from current date)

Expected behavior Write should be successfull

Screenshots

  • not needed

Version

$ ./victoria-metrics-prod --version
victoria-metrics-20201006-113018-tags-v1.43.0-0-g2a6fa5395

Used command-line flags ./victoria-metrics-prod -maxConcurrentInserts 1024 -memory.allowedPercent=40 -retentionPeriod=1200

Additional context The line of code says it clearly: https://github.com/VictoriaMetrics/VictoriaMetrics/blob/1f33dd717f2526462807f9337e76f54060b3031d/lib/storage/table.go#L380

This should be a bug, it is not uncommon to store data in the future, for example meteo weather forecast, those will be deleted and re-added after a new forecast is made, but that is normal.

prdatur avatar Oct 11 '20 22:10 prdatur

Please disable this limitation I need to store future data for my forecasts too

Denisplusplus avatar Dec 01 '20 08:12 Denisplusplus

Hi. Can you find time for this issue? It's very important for me too. We using your database because it very fast instead of Thanos and Prometheus.

stepanovmm1992 avatar Dec 07 '20 20:12 stepanovmm1992

VictoriaMetrics architecture has been designed with the assumption that timestamps for the ingested samples shouldn't go too far in the future. That's why there could be unexpected issues after removing this limitation. This needs additional investigation before allowing storing samples with timestamps from the future.

valyala avatar Dec 07 '20 21:12 valyala

We have the same case for storing future data for the forecasts. +1

mr-yaky avatar Mar 23 '21 18:03 mr-yaky

@valyala So, if I understood correct for now we can use at least the future timestamps till +2 days, right ? Does it make sense for the latest VM versions ?

mr-yaky avatar Mar 23 '21 18:03 mr-yaky

well, I think I found the answer after checking the code:

https://github.com/VictoriaMetrics/VictoriaMetrics/blob/cluster/lib/storage/table.go#L380

mr-yaky avatar Mar 23 '21 18:03 mr-yaky

VictoriaMetrics architecture has been designed with the assumption that timestamps for the ingested samples shouldn't go too far in the future. That's why there could be unexpected issues after removing this limitation. This needs additional investigation before allowing storing samples with timestamps from the future.

Do you have any more intuition as what "unexpected issues" might occur, or does even figuring that out involve a deep dive investigation? I'm looking to store forecast data for up to 30 days in the future, and am currently recompiling VM with the above mentioned line modified.

tedpearson avatar Dec 07 '21 04:12 tedpearson

@tedpearson Curious if you have this working. I tweaked it to a hardcoded value of 7 days (which meets my needs, but curious if you are using it with success with a longer duration?

ober37 avatar Apr 06 '22 21:04 ober37

@ober37 sorry for not getting back to you until now. I've had zero issues with my +30 day recompilation.

tedpearson avatar Sep 12 '22 00:09 tedpearson

Update for this issue:

For now, it’s not safe to allow ingestion metrics with timestamps bigger then 2 days. It’ll lead to incorrect metrics registration at the index and metrics will be partly available or unavailable for search after indexdb rotation.

f41gh7 avatar Dec 01 '22 13:12 f41gh7

Hey hey, is this still an unsolvable issue? Are there any updates?

Thanks in advance

namirsab avatar Feb 13 '23 12:02 namirsab

One stupid question: what could happen if we trick our VM server to be a few years in the future? As long as we don't have a retention time, it should be fine? That way we could hack this? 😅

namirsab avatar Mar 20 '23 18:03 namirsab

We're working with weather forecast and budget data as well - which is usually up to one year in the future. From my understanding of @f41gh7's analysis, just bumping the maxTimestamp variable to 365 or more instead of 2 days would cause pretty significant issues. Is @namirsab's approach maybe more effective, albeit technically maybe not super "clean"?

pvtpogopuschel avatar Mar 22 '23 10:03 pvtpogopuschel