Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PromQL: Promote negative offset and @ modifer to stable #10121

Merged
merged 3 commits into from Jan 12, 2022
Merged

Conversation

beorn7
Copy link
Member

@beorn7 beorn7 commented Jan 5, 2022

I hereby propose to promote the negative offset and the @ modifer to stable with v2.33. This PR can be used to discuss it. If we decide to postpone the promotion, we can keep it around and merge it once we are ready to do so.

Following the argument that breaking the invariant that PromQL does
not look ahead of the evaluation time implies a breaking change, we
still need to keep the feature flag around, but at least we can
communicate that the feature is considered stable, and that the
feature flags will be ignored from v3 on.

That's what this PR implements.

However, personally I still don't consider these features breaking changes. The invariant is only broken for queries that were invalid queries before the feature existed. I see how the new features are problematic for implementers of caching proxies, but there was never an explicit stability guarantee that PromQL would never have features that allow accessing samples newer than the query time. When we start to consider emerging behavioral patterns as stability guarantees, we could declare many new features or even improvements and bug fixes as breaking changes, breaking the invariant that they surely change some behavior. It's a question where to draw the line. That's ultimately a pragmatic decision without a precise answer. We probably all agree that the obligatory XKCD comic draws the line at the wrong level, but this case is more problematic. I would like to find out where you all would draw the line in this case. Perhaps we can after all just drop the feature flag and enable the features by default already now.

Copy link
Member

@codesome codesome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@juliusv
Copy link
Member

juliusv commented Jan 6, 2022 via email

@roidelapluie
Copy link
Member

I now also think if we have not a list of invariants documented, this is not a breaking change. Especially because it does not change existing queries results. This is an extra fonctionality at most .

@beorn7
Copy link
Member Author

beorn7 commented Jan 10, 2022

Thanks for the feedback. Since so far, you all agreed that the negative offset and the @ modifier should be a regular "always on" feature even in 2.x, I'll amend this PR to do so later today. But I'll wait until Wednesday to see if there are objections.

Following the argument that breaking the invariant that PromQL does
not look ahead of the evaluation time implies a breaking change, we
still need to keep the feature flag around, but at least we can
communicate that the feature is considered stable, and that the
feature flags will be ignored from v3 on.

Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7
Copy link
Member Author

beorn7 commented Jan 11, 2022

I pushed an additional commit that permanently enables negative offset and the @ modifier. If we decide that's the way to go, we leave the commit in. If we decide to keep those features behind a feature flag until v3.x, we simply remove the commit from the PR again.

Please let me know what you think. It would be cool to make the call by Wednesday, when I plan to cut the release candidate. (And since it is a release candidate only, we can still change our mind before the final release.)

@pstibrany
Copy link
Contributor

pstibrany commented Jan 11, 2022

I pushed an additional commit that permanently enables negative offset and the @ modifier. If we decide that's the way to go, we leave the commit in. If we decide to keep those features behind a feature flag until v3.x, we simply remove the commit from the PR again.

In Cortex we would prefer to be able to disable negative offsets (via field in EngineOpts struct) until we explore how to handle them properly with regards to caching. We also currently expose CLI flag to disable @-modifier, but we could remove that flag.

@beorn7
Copy link
Member Author

beorn7 commented Jan 11, 2022

So what does everyone think about leaving the various Opts structs in place, but not exposing them in prometheus and promtool?

@beorn7
Copy link
Member Author

beorn7 commented Jan 11, 2022

To extend on the latter: Those Opts structs and their handling would be "dead code" from the Prometheus perspective, but once we introduce the next feature flag for PromQL, it would come in handy to have all the plumbing in place already.

Since it also helps Cortex, I tend to do it that way (with some doc comments so that devs understand why it's there and aren't tempted to rip it out as "dead code").

If there is no other feedback within the next hours, I will amend this PR again to implement that idea.

@roidelapluie
Copy link
Member

Side note: if we enable them by default, they would become de facto part of the PromQL compatibility suite, so cloud providers and downstream projects will need to support that to be "Prometheus Compatible".

@roidelapluie
Copy link
Member

roidelapluie commented Jan 11, 2022

So what does everyone think about leaving the various Opts structs in place, but not exposing them in prometheus and promtool?

SGTM

This follows the line of argument that the invariant of not looking
ahead of the query time was merely emerging behavior and not a
documented stable feature. Any query that looks ahead of the query
time was simply invalid before the introduction of the negative offset
and the @ modifier.

Signed-off-by: beorn7 <beorn@grafana.com>
@beorn7
Copy link
Member Author

beorn7 commented Jan 11, 2022

OK, done. This now has the plumbing for the options in place, but in the prometheus and promtool binaries, both features are always enabled.

Copy link
Member

@roidelapluie roidelapluie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra nits:

  • Now those features are undocumented.
  • They should be always on in promql tests, too. Is it the case?

@beorn7
Copy link
Member Author

beorn7 commented Jan 11, 2022

The features are documented:

About the tests: You can pick for tests if they should be enabled or not, and both is still tested, which is important because we should still test the behavior when they are disabled as we are offering that behavior to users of the engine as a library.

@beorn7
Copy link
Member Author

beorn7 commented Jan 11, 2022

Oops, perhaps you were thinking about the PromQL tests (in testdata/...), which I ignored so far.

In fact, they already had EnableAtModifier enabled always, but not EnableNegativeOffset (simply because none of those tests used that). I will enable the latter, too, and add a test case with a negative offset.

Signed-off-by: beorn7 <beorn@grafana.com>
@juliusv
Copy link
Member

juliusv commented Jan 12, 2022

Looks good, thanks! 👍

For keeping the old options around, we just shouldn't do that for too long, as we shouldn't incentivize anyone using the PromQL engine code in a way that is not PromQL comaptible anymore. Maybe we can keep it for the same time frame as compliant and compatible marks are meant to be valid for: "Both compliant and compatible marks are valid for 2 minor releases or 12 weeks, whichever is longer." (from https://prometheus.io/blog/2021/05/03/introducing-prometheus-conformance-program/)

@beorn7
Copy link
Member Author

beorn7 commented Jan 12, 2022

I tend to agree. To make things easier for cache implementers, perhaps we can provide a way to find out which time range a query covers rather than just tagging features that potentially access a time range ahead of the query time.

In any case, that's for the future. I'll merge this now and will work on the changelog.

@beorn7 beorn7 merged commit 933f50b into main Jan 12, 2022
@beorn7 beorn7 deleted the beorn7/promql branch January 12, 2022 13:09
valyala added a commit to VictoriaMetrics/metricsql that referenced this pull request Jan 13, 2022
It is available via RollupExpr.At field.

Contrary to PromQL, MetricsQL accepts arbitrary expression as `@` modifier.
Also MetricsQL accepts `@` modifier at any place in the query.

Reference: prometheus/prometheus#10121 and https://prometheus.io/docs/prometheus/latest/querying/basics/#modifier

Updates VictoriaMetrics/VictoriaMetrics#1348
GiedriusS added a commit to GiedriusS/thanos that referenced this pull request Mar 18, 2022
Let's follow prometheus/prometheus#10121 and
make these into stable features as well.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
GiedriusS added a commit to GiedriusS/thanos that referenced this pull request Mar 18, 2022
Let's follow prometheus/prometheus#10121 and
make these into stable features as well.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
GiedriusS added a commit to GiedriusS/thanos that referenced this pull request Mar 18, 2022
Let's follow prometheus/prometheus#10121 and
make these into stable features as well.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
GiedriusS added a commit to GiedriusS/thanos that referenced this pull request Mar 18, 2022
Let's follow prometheus/prometheus#10121 and
make these into stable features as well.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
GiedriusS added a commit to GiedriusS/thanos that referenced this pull request Mar 18, 2022
Let's follow prometheus/prometheus#10121 and
make these into stable features as well.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
GiedriusS added a commit to thanos-io/thanos that referenced this pull request Mar 18, 2022
Let's follow prometheus/prometheus#10121 and
make these into stable features as well.

Signed-off-by: Giedrius Statkevičius <giedrius.statkevicius@vinted.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants