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

ES|QL: pin 'now' as query start time #113777

Merged
merged 3 commits into from
Oct 1, 2024

Conversation

luigidellaquila
Copy link
Contributor

Use now (already present in ESQL Configuration) to determine the start time of the query.
The serialization is already in place, so the value is already shared between the nodes.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine elasticsearchmachine added Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.0.0 labels Sep 30, 2024
@astefan astefan requested a review from nik9000 September 30, 2024 09:56
Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM

@bpintea
Copy link
Contributor

bpintea commented Oct 1, 2024

FTR: https://github.com/elastic/elasticsearch/pull/103474/files#r1427142330

I'm wondering if this method shouldn't be replaced with what it does on the result of now(), at it's sole invocation place in the ComputeService class. (Or, less ideal, maybe rename it to epochNow()?)

@astefan
Copy link
Contributor

astefan commented Oct 1, 2024

My original suggestion was to place the now initialization time in the constructor of the Configuration instead. I don't see why this now value should come from "outside", but in that PR things were considered differently and I didn't object.

@bpintea
Copy link
Contributor

bpintea commented Oct 1, 2024

My #112595 (comment) was to place the now initialization time in the constructor

👍
I guess it should work if all these should just use one nanos value, init'ed in c'tor. And I guess we can have a protected c'tor that takes the value too, for testing? Plus a now() method returning zoned time off it.

@luigidellaquila
Copy link
Contributor Author

My #112595 (comment) was to place the now initialization time in the constructor of the Configuration

Right now the initialization is in the constructor; I think we made the change when we removed EsqlConfiguration

About the "zoned" now, my understanding is that now.instant() will be an absolute value, independent from the zone, so we can rely on it, right?

@bpintea
Copy link
Contributor

bpintea commented Oct 1, 2024

the initialization is in the constructor

There are two times now, one init'ed in the c'tor (the old one), the other one passed in, added in the PR Andrei mentioned (a new one). We could/should make just one out of them.

so we can rely on it, right?

That's my understanding too.

@luigidellaquila
Copy link
Contributor Author

There are two times now

Oh, I was looking at the wrong place... 🤦

I'm not sure I fully understand the difference between absoluteStartedTimeInMillis and queryStartTimeNanos (apart from the precision).
now and absoluteStartedTimeInMillis are practically instantiated at the same time, and now has nanosecond precision, so maybe we can use it for both?

I don't know, I'm confused...

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

Seems right.

@nik9000
Copy link
Member

nik9000 commented Oct 1, 2024

I'm not sure I fully understand the difference between absoluteStartedTimeInMillis and queryStartTimeNanos (apart from the precision).

I'm not sure why we have the nanosecond one to be honest.

@nik9000
Copy link
Member

nik9000 commented Oct 1, 2024

I'm not sure why we have the nanosecond one to be honest.

Oh! Sorry one second.

@nik9000
Copy link
Member

nik9000 commented Oct 1, 2024

Oh! Sorry one second.

Ok. I don't see a queryStartTimeNanos, but in general nanosecond precision timers don't measure absolute time. They can't be used for "time since epoch" - they are relative timers. You can think of them as measuring time since process start. Or bootup. Or just some random time in the past.

The other thing is the NTP can change the absolute time. That's sort of it's job - time syncing. Generally NTP will change the absolute timers slowly, but if you are trying to figure out "how much time did this take" then stuff like NTP can get in the way. Sometimes you'll get negative numbers for "took" time if you use the absolute clock. But the relative clock is fine for this.

@luigidellaquila
Copy link
Contributor Author

stuff like NTP can get in the way

I'd say this is enough to keep now and queryStartTimeNanos separate.

@luigidellaquila luigidellaquila merged commit ee73969 into elastic:main Oct 1, 2024
16 checks passed
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x

luigidellaquila added a commit to luigidellaquila/elasticsearch that referenced this pull request Oct 1, 2024
@bpintea
Copy link
Contributor

bpintea commented Oct 1, 2024

I'd say this is enough to keep now and queryStartTimeNanos separate.

Since getQueryStartTimeNanos() is later subtracted again from System.nanoTime(), this makes sense.
But having a now() method along with absoluteStartedTimeInMillis(), which just returns the millis in now(), 🤷 .

elasticsearchmachine pushed a commit that referenced this pull request Oct 4, 2024
matthewabbott pushed a commit to matthewabbott/elasticsearch that referenced this pull request Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >non-issue Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants