Skip to content

Commit 319921e

Browse files
authored
prometheus: add patch for TestQuerierIndexQueriesRace (#12927)
1 parent 1e721f7 commit 319921e

3 files changed

Lines changed: 84 additions & 2 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From 41bc1097c65a402355dc2b0b9402811a78389b63 Mon Sep 17 00:00:00 2001
2+
From: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
3+
Date: Wed, 20 Sep 2023 17:41:33 +0200
4+
Subject: [PATCH] Fix exit condition of TestQuerierIndexQueriesRace
5+
6+
The test was introduced in # but was changed during the code review and not reran with the faulty code since then.
7+
8+
Closes #
9+
10+
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
11+
---
12+
tsdb/querier_test.go | 2 +-
13+
1 file changed, 1 insertion(+), 1 deletion(-)
14+
15+
diff --git a/tsdb/querier_test.go b/tsdb/querier_test.go
16+
index 8cfd5d141..2c5ff7477 100644
17+
--- a/tsdb/querier_test.go
18+
+++ b/tsdb/querier_test.go
19+
@@ -2248,7 +2248,7 @@ func TestQuerierIndexQueriesRace(t *testing.T) {
20+
func appendSeries(t *testing.T, ctx context.Context, wg *sync.WaitGroup, h *Head) {
21+
defer wg.Done()
22+
23+
- for i := 0; ctx.Err() != nil; i++ {
24+
+ for i := 0; ctx.Err() == nil; i++ {
25+
app := h.Appender(context.Background())
26+
_, err := app.Append(0, labels.FromStrings(labels.MetricName, "metric", "n", strconv.Itoa(i), "m", "0"), 0, 0)
27+
require.NoError(t, err)
28+
--
29+
2.33.8
30+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
From 0e66dc19b9f93c247dd938f8099626573df0e998 Mon Sep 17 00:00:00 2001
2+
From: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
3+
Date: Thu, 21 Sep 2023 12:30:08 +0200
4+
Subject: [PATCH] Improve sensitivity of TestQuerierIndexQueriesRace
5+
6+
Currently, the two goroutines race against each other and it's possible that the main test goroutine finishes way earlier than appendSeries has had a chance to run at all.
7+
8+
I tested this change by breaking the code that X fixed and running the race test 100 times. Without the additional time.Sleep the test failed 11 times. With the sleep it failed 65 out of the 100 runs. Which is still not ideal, but it's a step forward.
9+
10+
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
11+
---
12+
tsdb/querier_test.go | 5 +++++
13+
1 file changed, 5 insertions(+)
14+
15+
diff --git a/tsdb/querier_test.go b/tsdb/querier_test.go
16+
index 2c5ff7477..4938443c2 100644
17+
--- a/tsdb/querier_test.go
18+
+++ b/tsdb/querier_test.go
19+
@@ -2221,6 +2221,7 @@ func TestQuerierIndexQueriesRace(t *testing.T) {
20+
for _, c := range testCases {
21+
c := c
22+
t.Run(fmt.Sprintf("%v", c.matchers), func(t *testing.T) {
23+
+ t.Parallel()
24+
db := openTestDB(t, DefaultOptions(), nil)
25+
h := db.Head()
26+
t.Cleanup(func() {
27+
@@ -2240,6 +2241,9 @@ func TestQuerierIndexQueriesRace(t *testing.T) {
28+
values, _, err := q.LabelValues("n", c.matchers...)
29+
require.NoError(t, err)
30+
require.Emptyf(t, values, `label values for label "n" should be empty`)
31+
+
32+
+ // Sleep to give the appends some change to run.
33+
+ time.Sleep(time.Millisecond)
34+
}
35+
})
36+
}
37+
@@ -2256,6 +2260,7 @@ func appendSeries(t *testing.T, ctx context.Context, wg *sync.WaitGroup, h *Head
38+
require.NoError(t, err)
39+
40+
// Throttle down the appends to keep the test somewhat nimble.
41+
+ // Otherwise, we end up appending thousands or millions of samples.
42+
time.Sleep(time.Millisecond)
43+
}
44+
}
45+
--
46+
2.33.8
47+

SPECS/prometheus/prometheus.spec

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary: Prometheus monitoring system and time series database
55
Name: prometheus
66
Version: 2.45.4
7-
Release: 7%{?dist}
7+
Release: 8%{?dist}
88
License: Apache-2.0
99
Vendor: Microsoft Corporation
1010
Distribution: Azure Linux
@@ -22,6 +22,8 @@ Patch1: CVE-2023-45288.patch
2222
Patch2: CVE-2024-6104.patch
2323
Patch3: CVE-2024-24786.patch
2424
Patch4: CVE-2023-44487.patch
25+
Patch5: 0001-Fix-exit-condition-of-TestQuerierIndexQueriesRace.patch
26+
Patch6: 0002-Improve-sensitivity-of-TestQuerierIndexQueriesRace.patch
2527
BuildRequires: golang
2628
BuildRequires: nodejs
2729
BuildRequires: nodejs-npm
@@ -138,7 +140,10 @@ fi
138140
%doc README.md RELEASE.md documentation
139141

140142
%changelog
141-
* Tue Mar 04 2024 corvus-callidus <108946721+corvus-callidus@users.noreply.github.com> - 2.45.4-7
143+
* Thu Mar 13 2025 Andrew Phelps <anphel@microsoft.com> - 2.45.4-8
144+
- Add patches to fix test reliability issues with TestQuerierIndexQueriesRace
145+
146+
* Tue Mar 04 2025 corvus-callidus <108946721+corvus-callidus@users.noreply.github.com> - 2.45.4-7
142147
- Fix CVE-2023-44487
143148

144149
* Mon Nov 25 2024 Bala <balakumaran.kannan@microsoft.com> - 2.45.4-6

0 commit comments

Comments
 (0)