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

Implement query timeouts #498

Merged
merged 1 commit into from
Feb 3, 2015
Merged

Conversation

fabxc
Copy link
Contributor

@fabxc fabxc commented Feb 1, 2015

No description provided.

var stalenessDelta = flag.Duration("query.staleness-delta", 300*time.Second, "Staleness delta allowance during expression evaluations.")
var (
stalenessDelta = flag.Duration("query.staleness-delta", 300*time.Second, "Staleness delta allowance during expression evaluations.")
queryTimeout = flag.Duration("query.timeout", 30*time.Second, "Maximum time a query may take before being aborted.")
Copy link
Member

Choose a reason for hiding this comment

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

In the end this should be user-configurable via a query parameter. But for now, a flag with a default seems ok. Let's set the default to 2 minutes though (based on experience with heavy datasets and some rare, but useful, expensive queries).

@fabxc fabxc closed this Feb 1, 2015
@juliusv
Copy link
Member

juliusv commented Feb 1, 2015

@fabxc did you close this PR intentionally?

@fabxc
Copy link
Contributor Author

fabxc commented Feb 2, 2015

Missed some stuff and wanted to make some changes before bothering anyone with reviewing - but you already commented ;)

Relying on the TotalEvalTimer breaks a few tests and requires to manually start it before calling ast.EvalTo*. It's not exactly pretty, but works if I change the relevant parts.

@fabxc fabxc reopened this Feb 2, 2015
@@ -40,6 +40,11 @@ func (t *Timer) Stop() {
t.duration += time.Since(t.start)
}

// Return the elapsed time up to now
Copy link
Member

Choose a reason for hiding this comment

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

s/now/now./

(sentence-style comments with periods: https://code.google.com/p/go-wiki/wiki/CodeReviewComments#Comment_Sentences)

@juliusv
Copy link
Member

juliusv commented Feb 2, 2015

@fabxc Ah ok. Sorry for being so fast :) I'm actually going to head to bed now and have another look at it tomorrow and will see if @beorn7 has some additional opinions about how the timeouts should be handled. Until then - thanks!

@fabxc
Copy link
Contributor Author

fabxc commented Feb 2, 2015

Things are fixed now, more transparency would be nice though.
My initial approach was to give the preloader an ActivateTimeout(t) method which was way cleaner but not covering the whole evaluation process.

var stalenessDelta = flag.Duration("query.staleness-delta", 300*time.Second, "Staleness delta allowance during expression evaluations.")
var (
stalenessDelta = flag.Duration("query.staleness-delta", 300*time.Second, "Staleness delta allowance during expression evaluations.")
queryTimeout = flag.Duration("query.timeout", 2*time.Minute, "Maximum time a query may take before being aborted.")
Copy link
Member

Choose a reason for hiding this comment

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

Referring to @juliusv 's comment: We definitely want a timeout configurable per query later, but then we still need this flag as a default value if no timeout is requested in the query. We only have to change the docstring then..

@beorn7
Copy link
Member

beorn7 commented Feb 2, 2015

Hi @fabxc , thanks for your contribution.

I believe you have forgotten to add the changes of timer.go to this PR.

@beorn7
Copy link
Member

beorn7 commented Feb 2, 2015

Sorry, my bad, now I can see the changes. Was in the wrong repo...

@@ -40,6 +40,11 @@ func (t *Timer) Stop() {
t.duration += time.Since(t.start)
}

// Return the elapsed time up to now.
Copy link
Member

Choose a reason for hiding this comment

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

Start doc comment with "ElapsedTIme ...". golint catches things like that.

@beorn7
Copy link
Member

beorn7 commented Feb 2, 2015

@juliusv That comment is attached to an outdated diff... GH reviewing... meh...

@juliusv
Copy link
Member

juliusv commented Feb 3, 2015

@fabxc So I looked over this again, and besides our musings about future possibilities, this looks great. I'll merge it unless you had anything you still wanted to add or change?

Thanks!

@juliusv
Copy link
Member

juliusv commented Feb 3, 2015

(oh, but please squash this into one or two meaningful commits before merging)

@juliusv juliusv changed the title Feature/query timeout Implement query timeouts Feb 3, 2015
This is related to prometheus#454. Queries now timeout after a duration set by
the -query.timeout flag. The TotalEvalTimer is now started/stopped
inside any of the ast.Eval* functions.
@fabxc fabxc force-pushed the feature/query_timeout branch from bbfaca1 to fa1e900 Compare February 3, 2015 07:09
@fabxc
Copy link
Contributor Author

fabxc commented Feb 3, 2015

Done.

@juliusv
Copy link
Member

juliusv commented Feb 3, 2015

Woot, thanks!

juliusv added a commit that referenced this pull request Feb 3, 2015
@juliusv juliusv merged commit 9e6b3bc into prometheus:master Feb 3, 2015
simonpasquier pushed a commit to simonpasquier/prometheus that referenced this pull request Oct 12, 2017
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.

3 participants