InfluxDB: Revert calculation of maxPointsEnforced value (#88809)

revert calculation of maxPointsEnforced
This commit is contained in:
ismail simsek
2024-06-05 21:43:04 +02:00
committed by GitHub
parent a87c155c06
commit 08276bd8e7
3 changed files with 35 additions and 194 deletions
+2 -7
View File
@@ -29,13 +29,8 @@ func executeQuery(ctx context.Context, logger log.Logger, query queryModel, runn
logger.Warn("Flux query failed", "err", err, "query", flux)
dr.Error = err
} else {
maxPointsEnforced := int(query.MaxDataPoints)
// The default value of MaxDataPoints is 100 when it is not set
// See https://github.com/grafana/grafana/blob/d69b19e431bfe31ff904a48826593e6fa79b7a5b/pkg/services/query/query.go#L322
// So if the default value is being used we fall back to the old logic.
if query.MaxDataPoints == 100 {
maxPointsEnforced *= int(maxPointsEnforceFactor)
}
// we only enforce a larger number than maxDataPoints
maxPointsEnforced := int(float64(query.MaxDataPoints) * maxPointsEnforceFactor)
dr = readDataFrames(logger, tables, maxPointsEnforced, maxSeries)
+4 -4
View File
@@ -250,8 +250,8 @@ func TestMaxDataPointsExceededNoAggregate(t *testing.T) {
dr := executeMockedQuery(t, "max_data_points_exceeded", queryModel{MaxDataPoints: 2})
// it should contain the error-message
require.EqualError(t, dr.Error, "A query returned too many datapoints and the results have been truncated at 3 points to prevent memory issues. At the current graph size, Grafana can only draw 2. Try using the aggregateWindow() function in your query to reduce the number of points returned.")
assertDataResponseDimensions(t, dr, 2, 3)
require.EqualError(t, dr.Error, "A query returned too many datapoints and the results have been truncated at 21 points to prevent memory issues. At the current graph size, Grafana can only draw 2. Try using the aggregateWindow() function in your query to reduce the number of points returned.")
assertDataResponseDimensions(t, dr, 2, 21)
}
func TestMaxDataPointsExceededWithAggregate(t *testing.T) {
@@ -261,8 +261,8 @@ func TestMaxDataPointsExceededWithAggregate(t *testing.T) {
dr := executeMockedQuery(t, "max_data_points_exceeded", queryModel{RawQuery: "aggregateWindow()", MaxDataPoints: 2})
// it should contain the error-message
require.EqualError(t, dr.Error, "A query returned too many datapoints and the results have been truncated at 3 points to prevent memory issues. At the current graph size, Grafana can only draw 2.")
assertDataResponseDimensions(t, dr, 2, 3)
require.EqualError(t, dr.Error, "A query returned too many datapoints and the results have been truncated at 21 points to prevent memory issues. At the current graph size, Grafana can only draw 2.")
assertDataResponseDimensions(t, dr, 2, 21)
}
func TestMultivalue(t *testing.T) {