From 55dcaab41bedc995460927a2c4f3e977d23c374c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 16 Nov 2023 14:35:44 +0000 Subject: [PATCH] Fix TestScrapeLoopDiscardDuplicateLabels test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This test calls Rollback() which is normally called from within append code. Doing so means that staleness tracking data is outdated and need to by cycled manually. Signed-off-by: Ɓukasz Mierzwa --- scrape/scrape_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scrape/scrape_test.go b/scrape/scrape_test.go index 4732fbe0d..dbe9f0bb2 100644 --- a/scrape/scrape_test.go +++ b/scrape/scrape_test.go @@ -2636,6 +2636,9 @@ func TestScrapeLoopDiscardDuplicateLabels(t *testing.T) { _, _, _, err := sl.append(slApp, []byte("test_metric{le=\"500\"} 1\ntest_metric{le=\"600\",le=\"700\"} 1\n"), "", time.Time{}) require.Error(t, err) require.NoError(t, slApp.Rollback()) + // We need to cycle staleness cache maps after a manual rollback. Otherwise they will have old entries in them, + // which would cause ErrDuplicateSampleForTimestamp errors on the next append. + sl.cache.iterDone(true) q, err := s.Querier(time.Time{}.UnixNano(), 0) require.NoError(t, err)