Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jhesketh committed Aug 28, 2024
1 parent 2db41dd commit a0fd5fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pkg/streamingpromql/limiting/memory_consumption.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (l *MemoryConsumptionTracker) IncreaseMemoryConsumption(b uint64) error {
// DecreaseMemoryConsumption decreases the current memory consumption by b bytes.
func (l *MemoryConsumptionTracker) DecreaseMemoryConsumption(b uint64) {
if b > l.CurrentEstimatedMemoryConsumptionBytes {
panic("Memory consumption tracking is negative. This indicates something has been returned to a pool more than once.")
panic("Estimated memory consumption of this query is negative. This indicates something has been returned to a pool more than once, which is a bug.")
}
l.CurrentEstimatedMemoryConsumptionBytes -= b
}
16 changes: 2 additions & 14 deletions pkg/streamingpromql/limiting/memory_consumption_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,7 @@ func TestMemoryConsumptionTracker_Unlimited(t *testing.T) {
assertRejectedQueriesCount(t, reg, 0)

// Test reducing memory consumption to a negative panics
defer func() {
if r := recover(); r == nil {
t.Errorf("We did not panic on negative memory consumption")
}
}()

tracker.DecreaseMemoryConsumption(150)
require.Panics(t, func() { tracker.DecreaseMemoryConsumption(150) })
}

func TestMemoryConsumptionTracker_Limited(t *testing.T) {
Expand Down Expand Up @@ -104,13 +98,7 @@ func TestMemoryConsumptionTracker_Limited(t *testing.T) {
assertRejectedQueriesCount(t, reg, 1)

// Test reducing memory consumption to a negative panics
defer func() {
if r := recover(); r == nil {
t.Errorf("We did not panic on negative memory consumption")
}
}()

tracker.DecreaseMemoryConsumption(150)
require.Panics(t, func() { tracker.DecreaseMemoryConsumption(150) })
}

func assertRejectedQueriesCount(t *testing.T, reg *prometheus.Registry, expectedRejectionCount int) {
Expand Down

0 comments on commit a0fd5fc

Please sign in to comment.