-
Notifications
You must be signed in to change notification settings - Fork 348
Add Request Timeouts #1431
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
Add Request Timeouts #1431
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,9 @@ dependencies { | |
| implementation("com.fasterxml.jackson.core:jackson-annotations") | ||
| implementation("com.fasterxml.jackson.core:jackson-core") | ||
| implementation("com.fasterxml.jackson.core:jackson-databind") | ||
|
|
||
| compileOnly(platform(libs.quarkus.bom)) | ||
| compileOnly("io.quarkus:quarkus-smallrye-fault-tolerance") | ||
|
||
| } | ||
|
|
||
| openApiGenerate { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,9 @@ quarkus.otel.sdk.disabled=true | |
|
|
||
| quarkus.test.integration-test-profile=it | ||
|
|
||
| quarkus.fault-tolerance.global.timeout.unit=seconds | ||
| quarkus.fault-tolerance.global.timeout.value=60 | ||
|
||
|
|
||
| polaris.realm-context.type=default | ||
| polaris.realm-context.realms=POLARIS | ||
| polaris.realm-context.header-name=Polaris-Realm | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,8 @@ import {{javaxPackage}}.inject.Inject; | |
|
|
||
| import org.apache.polaris.core.context.RealmContext; | ||
|
|
||
| import org.eclipse.microprofile.faulttolerance.Timeout; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
|
|
@@ -108,6 +110,7 @@ public class {{classname}} { | |
| @Produces({ {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} }){{/hasProduces}}{{#hasAuthMethods}} | ||
| {{#authMethods}}{{#isOAuth}}@RolesAllowed("**"){{/isOAuth}}{{/authMethods}}{{/hasAuthMethods}} | ||
| @Timed("{{metricsPrefix}}.{{baseName}}.{{nickname}}") | ||
| @Timeout | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How is the timeout actually defined?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure this change is beneficial... Clients should control their own timeouts (in general). If this annotation cancels the related HTTP request, will it actually cancel the server-side processing?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Within Open Catalog, server-side timeouts have been very useful for protecting the service from very long-running requests. Clients can of course have their own timeouts, but I think server side timeouts are very beneficial. Agreed that this only makes sense if the server-side processing actually gets cancelled
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Quarkus configs - I added a default value of 60s to the default
The API method will throw a
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That is clear :) What happens to the server threads that are still executing the request that timed out?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After reading the docs :) I guess the server thread will get a simple java interrupt, which does look useful. Sorry, I should have paid more attention to this PR initially 🤦 It LGTM (assuming longer default timeput), but let's collect some more reviews, though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default is 1 second. To disable the Timeout, we can disable Quarkus fault tolerance which I did in |
||
| public Response {{nickname}}({{#isMultipart}}MultipartFormDataInput input,{{/isMultipart}}{{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{^isMultipart}}{{>formParams}},{{/isMultipart}}{{#isMultipart}}{{^isFormParam}},{{/isFormParam}}{{/isMultipart}}{{/allParams}}@Context @MeterTag(key="realm_id",expression="realmIdentifier") RealmContext realmContext,@Context SecurityContext securityContext) { | ||
| {{! Don't log form or header params in case there are secrets, e.g., OAuth tokens }} | ||
| LOGGER.atDebug().setMessage("Invoking {{baseName}} with params") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we do not need the Quarkus BOM here. Could we add a specific local version for
org.eclipse.microprofile.fault-tolerance:microprofile-fault-tolerance-apito the TOML file? Since the dep is compile-only, version mismatches should not be a problem. WDYT?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this was my main concern initially, but I did not property research and articulate it 🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a version for
microprofile-fault-tolerance-apito the toml file, which is the same version brought in by the current version of Quarkus.