From b8b0d45d6982a1587acb669409982b6917620db0 Mon Sep 17 00:00:00 2001 From: Ganesh Vernekar Date: Wed, 30 Nov 2022 17:49:33 +0530 Subject: [PATCH 1/2] Fix reset of a histogram chunk iterator Signed-off-by: Ganesh Vernekar --- tsdb/chunkenc/histogram.go | 4 ++-- tsdb/chunkenc/histogram_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tsdb/chunkenc/histogram.go b/tsdb/chunkenc/histogram.go index 6e326888a..e57b96db9 100644 --- a/tsdb/chunkenc/histogram.go +++ b/tsdb/chunkenc/histogram.go @@ -624,9 +624,9 @@ func (it *histogramIterator) Err() error { } func (it *histogramIterator) Reset(b []byte) { - // The first 2 bytes contain chunk headers. + // The first 3 bytes contain chunk headers. // We skip that for actual samples. - it.br = newBReader(b[2:]) + it.br = newBReader(b[3:]) it.numTotal = binary.BigEndian.Uint16(b) it.numRead = 0 diff --git a/tsdb/chunkenc/histogram_test.go b/tsdb/chunkenc/histogram_test.go index 1a187667c..09c08ae3c 100644 --- a/tsdb/chunkenc/histogram_test.go +++ b/tsdb/chunkenc/histogram_test.go @@ -84,14 +84,14 @@ func TestHistogramChunkSameBuckets(t *testing.T) { require.Equal(t, exp, act) // 2. Expand second iterator while reusing first one. - // it2 := c.Iterator(it1) - // var res2 []pair - // for it2.Next() { - // ts, v := it2.At() - // res2 = append(res2, pair{t: ts, v: v}) - // } - // require.NoError(t, it2.Err()) - // require.Equal(t, exp, res2) + it2 := c.Iterator(it) + var res2 []res + for it2.Next() == ValHistogram { + ts, h := it2.AtHistogram() + res2 = append(res2, res{t: ts, h: h}) + } + require.NoError(t, it2.Err()) + require.Equal(t, exp, res2) // 3. Test iterator Seek. // mid := len(exp) / 2 From 44af4716c86138869aa621737139e6dacf0e2550 Mon Sep 17 00:00:00 2001 From: Ganesh Vernekar Date: Thu, 1 Dec 2022 18:16:11 +0530 Subject: [PATCH 2/2] Cut v2.40.5 (#11646) Signed-off-by: Ganesh Vernekar --- CHANGELOG.md | 4 ++++ VERSION | 2 +- web/ui/module/codemirror-promql/package.json | 4 ++-- web/ui/module/lezer-promql/package.json | 2 +- web/ui/package-lock.json | 14 +++++++------- web/ui/react-app/package.json | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a68ed6627..4dba2e19d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.40.5 / 2022-12-01 + +* [BUGFIX] TSDB: Fix queries involving native histograms due to improper reset of iterators. #11643 + ## 2.40.4 / 2022-11-29 * [SECURITY] Fix basic authentication bypass vulnerability (CVE-2022-46146). GHSA-4v48-4q5m-8vx4 diff --git a/VERSION b/VERSION index 2d6c3fe67..0644c8fe6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.40.4 +2.40.5 diff --git a/web/ui/module/codemirror-promql/package.json b/web/ui/module/codemirror-promql/package.json index 0b8743728..7eab09449 100644 --- a/web/ui/module/codemirror-promql/package.json +++ b/web/ui/module/codemirror-promql/package.json @@ -1,6 +1,6 @@ { "name": "@prometheus-io/codemirror-promql", - "version": "0.40.4", + "version": "0.40.5", "description": "a CodeMirror mode for the PromQL language", "types": "dist/esm/index.d.ts", "module": "dist/esm/index.js", @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/prometheus/prometheus/blob/main/web/ui/module/codemirror-promql/README.md", "dependencies": { - "@prometheus-io/lezer-promql": "^0.40.4", + "@prometheus-io/lezer-promql": "^0.40.5", "lru-cache": "^6.0.0" }, "devDependencies": { diff --git a/web/ui/module/lezer-promql/package.json b/web/ui/module/lezer-promql/package.json index 6a8beb98a..0ffb9e5f7 100644 --- a/web/ui/module/lezer-promql/package.json +++ b/web/ui/module/lezer-promql/package.json @@ -1,6 +1,6 @@ { "name": "@prometheus-io/lezer-promql", - "version": "0.40.4", + "version": "0.40.5", "description": "lezer-based PromQL grammar", "main": "index.cjs", "type": "module", diff --git a/web/ui/package-lock.json b/web/ui/package-lock.json index 23afbdca7..bc5b81c6e 100644 --- a/web/ui/package-lock.json +++ b/web/ui/package-lock.json @@ -28,10 +28,10 @@ }, "module/codemirror-promql": { "name": "@prometheus-io/codemirror-promql", - "version": "0.40.4", + "version": "0.40.5", "license": "Apache-2.0", "dependencies": { - "@prometheus-io/lezer-promql": "^0.40.4", + "@prometheus-io/lezer-promql": "^0.40.5", "lru-cache": "^6.0.0" }, "devDependencies": { @@ -61,7 +61,7 @@ }, "module/lezer-promql": { "name": "@prometheus-io/lezer-promql", - "version": "0.40.4", + "version": "0.40.5", "license": "Apache-2.0", "devDependencies": { "@lezer/generator": "^1.1.1", @@ -17625,7 +17625,7 @@ }, "react-app": { "name": "@prometheus-io/app", - "version": "0.40.4", + "version": "0.40.5", "dependencies": { "@codemirror/autocomplete": "^6.2.0", "@codemirror/commands": "^6.1.0", @@ -17643,7 +17643,7 @@ "@lezer/lr": "^1.2.3", "@nexucis/fuzzy": "^0.4.1", "@nexucis/kvsearch": "^0.8.1", - "@prometheus-io/codemirror-promql": "^0.40.4", + "@prometheus-io/codemirror-promql": "^0.40.5", "bootstrap": "^4.6.2", "css.escape": "^1.5.1", "downshift": "^6.1.11", @@ -19883,7 +19883,7 @@ "@lezer/lr": "^1.2.3", "@nexucis/fuzzy": "^0.4.1", "@nexucis/kvsearch": "^0.8.1", - "@prometheus-io/codemirror-promql": "^0.40.4", + "@prometheus-io/codemirror-promql": "^0.40.5", "@testing-library/react-hooks": "^7.0.2", "@types/enzyme": "^3.10.12", "@types/flot": "0.0.32", @@ -19935,7 +19935,7 @@ "@lezer/common": "^1.0.1", "@lezer/highlight": "^1.1.0", "@lezer/lr": "^1.2.3", - "@prometheus-io/lezer-promql": "^0.40.4", + "@prometheus-io/lezer-promql": "^0.40.5", "@types/lru-cache": "^5.1.1", "isomorphic-fetch": "^3.0.0", "lru-cache": "^6.0.0", diff --git a/web/ui/react-app/package.json b/web/ui/react-app/package.json index 5bd05ca32..f1b5edca6 100644 --- a/web/ui/react-app/package.json +++ b/web/ui/react-app/package.json @@ -1,6 +1,6 @@ { "name": "@prometheus-io/app", - "version": "0.40.4", + "version": "0.40.5", "private": true, "dependencies": { "@codemirror/autocomplete": "^6.2.0", @@ -19,7 +19,7 @@ "@lezer/common": "^1.0.1", "@nexucis/fuzzy": "^0.4.1", "@nexucis/kvsearch": "^0.8.1", - "@prometheus-io/codemirror-promql": "^0.40.4", + "@prometheus-io/codemirror-promql": "^0.40.5", "bootstrap": "^4.6.2", "css.escape": "^1.5.1", "downshift": "^6.1.11",