nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: VictoriaMetrics/VictoriaMetrics
Pull request #5814 (2024-02-15 19:19:54)

[lib/httputils] fixed floating-point error when parsing time in RFC3339 format
issue #5801


Patch:
diff --git a/app/vmctl/time.go b/app/vmctl/time.go
index 43dd7588d..55652475c 100644
--- a/app/vmctl/time.go
+++ b/app/vmctl/time.go
@@ -2,6 +2,7 @@ package main
 
 import (
 	"fmt"
+	"math"
 	"time"
 
 	"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
@@ -18,7 +19,7 @@ func parseTime(s string) (time.Time, error) {
 	if err != nil {
 		return time.Time{}, fmt.Errorf("cannot parse %s: %w", s, err)
 	}
-	msecs := int64(secs * 1e3)
+	msecs := int64(math.Round(secs * 1e3))
 	if msecs < minTimeMsecs {
 		msecs = 0
 	}
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index a7c498ec5..2b788d4d9 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -40,6 +40,7 @@ See also [LTS releases](https://docs.victoriametrics.com/LTS-releases.html).
 
 * BUGFIX: fix the misleading error `0ms is out of allowed range [0 ...` when passing `step=0` to [/api/v1/query](https://docs.victoriametrics.com/keyconcepts/#instant-query)
   or [/api/v1/query_range](https://docs.victoriametrics.com/keyconcepts/#range-query). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5795).
+* BUGFIX: [Single-node VictoriaMetrics](https://docs.victoriametrics.com/) and `vmselect` in [VictoriaMetrics cluster](https://docs.victoriametrics.com/cluster-victoriametrics/): fixed floating-point error when parsing time in RFC3339 format. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5801) for details.
 * BUGFIX: [vmalert](https://docs.victoriametrics.com/#vmalert): consistently sort groups by name and filename on `/groups` page in UI. This should prevent non-deterministic sorting for groups with identical names.
 
 ## [v1.98.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.98.0)
diff --git a/lib/httputils/time.go b/lib/httputils/time.go
index e55591251..0ad156575 100644
--- a/lib/httputils/time.go
+++ b/lib/httputils/time.go
@@ -32,7 +32,7 @@ func GetTime(r *http.Request, argKey string, defaultMs int64) (int64, error) {
 	if err != nil {
 		return 0, fmt.Errorf("cannot parse %s=%s: %w", argKey, argValue, err)
 	}
-	msecs := int64(secs * 1e3)
+	msecs := int64(math.Round(secs * 1e3))
 	if msecs < minTimeMsecs {
 		msecs = 0
 	}


Test patch:
diff --git a/lib/httputils/time_test.go b/lib/httputils/time_test.go
index 949b3e47d..73667e719 100644
--- a/lib/httputils/time_test.go
+++ b/lib/httputils/time_test.go
@@ -47,6 +47,7 @@ func TestGetTimeSuccess(t *testing.T) {
 	f("2019-02-02T01:01:00", 1549069260000)
 	f("2019-02-02T01:01:01", 1549069261000)
 	f("2019-07-07T20:01:02Z", 1562529662000)
+	f("2020-02-21T16:07:49.433Z", 1582301269433)
 	f("2019-07-07T20:47:40+03:00", 1562521660000)
 	f("-292273086-05-16T16:47:06Z", minTimeMsecs)
 	f("292277025-08-18T07:12:54.999999999Z", maxTimeMsecs)
Repository: VictoriaMetrics/VictoriaMetrics
Pull request #6118 (2024-04-16 12:15:04)

lib/mergeset: improve test coverage
Add test to cover the code path with overflowing shards buffers and triggering merge to partition.

This test covers the code path which leaded to https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5959


Patch:
diff --git a/lib/mergeset/table.go b/lib/mergeset/table.go
index 52cc74ea8..628634c3d 100644
--- a/lib/mergeset/table.go
+++ b/lib/mergeset/table.go
@@ -167,7 +167,7 @@ var rawItemsShardsPerTable = func() int {
 	return cpus * multiplier
 }()
 
-const maxBlocksPerShard = 256
+var maxBlocksPerShard = 256
 
 func (riss *rawItemsShards) init() {
 	riss.shards = make([]rawItemsShard, rawItemsShardsPerTable)


Test patch:
diff --git a/lib/mergeset/table_test.go b/lib/mergeset/table_test.go
index e044ab34a..810dd5a04 100644
--- a/lib/mergeset/table_test.go
+++ b/lib/mergeset/table_test.go
@@ -176,6 +176,66 @@ func TestTableCreateSnapshotAt(t *testing.T) {
 	_ = os.RemoveAll(path)
 }
 
+func TestTableAddItemsConcurrentStress(t *testing.T) {
+	const path = "TestTableAddItemsConcurrentStress"
+	if err := os.RemoveAll(path); err != nil {
+		t.Fatalf("cannot remove %q: %s", path, err)
+	}
+	defer func() {
+		_ = os.RemoveAll(path)
+	}()
+
+	rawItemsShardsPerTableOrig := rawItemsShardsPerTable
+	maxBlocksPerShardOrig := maxBlocksPerShard
+	rawItemsShardsPerTable = 10
+	maxBlocksPerShard = 3
+	defer func() {
+		rawItemsShardsPerTable = rawItemsShardsPerTableOrig
+		maxBlocksPerShard = maxBlocksPerShardOrig
+	}()
+
+	var flushes atomic.Uint64
+	flushCallback := func() {
+		flushes.Add(1)
+	}
+	prepareBlock := func(data []byte, items []Item) ([]byte, []Item) {
+		return data, items
+	}
+
+	blocksNeeded := rawItemsShardsPerTable * maxBlocksPerShard * 10
+	testAddItems := func(tb *Table) {
+		itemsBatch := make([][]byte, 0)
+
+		for j := 0; j < blocksNeeded; j++ {
+			item := bytes.Repeat([]byte{byte(j)}, maxInmemoryBlockSize-10)
+			itemsBatch = append(itemsBatch, item)
+		}
+		tb.AddItems(itemsBatch)
+	}
+
+	var isReadOnly atomic.Bool
+	tb := MustOpenTable(path, flushCallback, prepareBlock, &isReadOnly)
+
+	testAddItems(tb)
+
+	// Verify items count after pending items flush.
+	tb.DebugFlush()
+	if flushes.Load() == 0 {
+		t.Fatalf("unexpected zero flushes")
+	}
+
+	var m TableMetrics
+	tb.UpdateMetrics(&m)
+	if n := m.TotalItemsCount(); n != uint64(blocksNeeded) {
+		t.Fatalf("unexpected itemsCount; got %d; want %v", n, blocksNeeded)
+	}
+
+	tb.MustClose()
+
+	// Re-open the table and make sure itemsCount remains the same.
+	testReopenTable(t, path, blocksNeeded)
+}
+
 func TestTableAddItemsConcurrent(t *testing.T) {
 	const path = "TestTableAddItemsConcurrent"
 	if err := os.RemoveAll(path); err != nil {
Repository: VictoriaMetrics/VictoriaMetrics
Pull request #6348 (2024-05-25 04:11:18)

chore: remove redundant words
### Describe Your Changes

remove redundant words

### Checklist

The following checks are **mandatory**:

- [ ] My change adheres [VictoriaMetrics contributing guidelines](https://docs.victoriametrics.com/contributing/).



Patch:
diff --git a/app/vmctl/opentsdb/opentsdb.go b/app/vmctl/opentsdb/opentsdb.go
index 4efc18c6c..b75e20b5a 100644
--- a/app/vmctl/opentsdb/opentsdb.go
+++ b/app/vmctl/opentsdb/opentsdb.go
@@ -26,7 +26,7 @@ type Retention struct {
 	FirstOrder  string
 	SecondOrder string
 	AggTime     string
-	// The actual ranges will will attempt to query (as offsets from now)
+	// The actual ranges will attempt to query (as offsets from now)
 	QueryRanges []TimeRange
 }
 
diff --git a/docs/stream-aggregation.md b/docs/stream-aggregation.md
index f94b42e49..daaa59e4b 100644
--- a/docs/stream-aggregation.md
+++ b/docs/stream-aggregation.md
@@ -1073,7 +1073,7 @@ This may lead to the following issues:
   since they ignore the first sample in a new time series.
 - Unexpected spikes for [total](#total) and [increase](#increase) outputs, since they assume that new time series start from 0.
 
-These issues can be be fixed in the following ways:
+These issues can be fixed in the following ways:
 
 - By increasing the `interval` option at [stream aggregation config](#stream-aggregation-config), so it covers the expected
   delays in data ingestion pipelines.


Test patch:
diff --git a/app/vmagent/remotewrite/pendingseries_test.go b/app/vmagent/remotewrite/pendingseries_test.go
index 487fdab49..6e949a94f 100644
--- a/app/vmagent/remotewrite/pendingseries_test.go
+++ b/app/vmagent/remotewrite/pendingseries_test.go
@@ -34,7 +34,7 @@ func testPushWriteRequest(t *testing.T, rowsCount, expectedBlockLenProm, expecte
 			return true
 		}
 		if !tryPushWriteRequest(wr, pushBlock, isVMRemoteWrite) {
-			t.Fatalf("cannot push data to to remote storage")
+			t.Fatalf("cannot push data to remote storage")
 		}
 		if math.Abs(float64(pushBlockLen-expectedBlockLen)/float64(expectedBlockLen)*100) > tolerancePrc {
 			t.Fatalf("unexpected block len for rowsCount=%d, isVMRemoteWrite=%v; got %d bytes; expecting %d bytes +- %.0f%%",