From 168d8d4f5ff80290456a03082a97839694b77870 Mon Sep 17 00:00:00 2001 From: David Leadbeater Date: Mon, 15 Mar 2021 13:05:17 +0000 Subject: [PATCH 1/2] Ensure that timestamp comparison uses wall clock time (backport #8601) It's not possible to assume subtraction and addition of a time.Time will result in consistent values. Signed-off-by: David Leadbeater --- scrape/scrape.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scrape/scrape.go b/scrape/scrape.go index bd89b69f6..f544d4a00 100644 --- a/scrape/scrape.go +++ b/scrape/scrape.go @@ -1005,7 +1005,7 @@ func (sl *scrapeLoop) run(interval, timeout time.Duration, errc chan<- error) { var last time.Time - alignedScrapeTime := time.Now() + alignedScrapeTime := time.Now().Round(0) ticker := time.NewTicker(interval) defer ticker.Stop() @@ -1023,7 +1023,9 @@ mainLoop: // Temporary workaround for a jitter in go timers that causes disk space // increase in TSDB. // See https://github.com/prometheus/prometheus/issues/7846 - scrapeTime := time.Now() + // Calling Round ensures the time used is the wall clock, as otherwise .Sub + // and .Add on time.Time behave differently (see time package docs). + scrapeTime := time.Now().Round(0) if AlignScrapeTimestamps && interval > 100*scrapeTimestampTolerance { // For some reason, a tick might have been skipped, in which case we // would call alignedScrapeTime.Add(interval) multiple times. From f9692a68465fe248c77bee6ef07141decff3d6f4 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Tue, 16 Mar 2021 16:43:10 +0100 Subject: [PATCH 2/2] Release 2.25.2 Signed-off-by: Julien Pivotto --- CHANGELOG.md | 4 ++++ VERSION | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f029caf1..dab6de1c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.25.2 / 2021-03-16 + +* [BUGFIX] Fix the ingestion of scrapes when the wall clock changes, e.g. on suspend. #8601 + ## 2.25.1 / 2021-03-14 * [BUGFIX] Fix a crash in `promtool` when a subquery with default resolution is used. #8569 diff --git a/VERSION b/VERSION index d6af7e332..40a8d7f12 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.25.1 +2.25.2