-
Notifications
You must be signed in to change notification settings - Fork 331
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 all 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 |
|---|---|---|
|
|
@@ -71,6 +71,8 @@ dependencies { | |
| implementation("com.fasterxml.jackson.core:jackson-annotations") | ||
| implementation("com.fasterxml.jackson.core:jackson-core") | ||
| implementation("com.fasterxml.jackson.core:jackson-databind") | ||
|
|
||
| compileOnly(libs.microprofile.fault.tolerance.api) | ||
|
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. nit: could you move this together with the other compile deps too?
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. This is also the only compile dep :)) |
||
| } | ||
|
|
||
| openApiGenerate { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,7 @@ javax-servlet-api = { module = "javax.servlet:javax.servlet-api", version = "4.0 | |
| junit-bom = { module = "org.junit:junit-bom", version = "5.12.2" } | ||
| logback-classic = { module = "ch.qos.logback:logback-classic", version = "1.5.18" } | ||
| micrometer-bom = { module = "io.micrometer:micrometer-bom", version = "1.14.6" } | ||
| microprofile-fault-tolerance-api = { module = "org.eclipse.microprofile.fault-tolerance:microprofile-fault-tolerance-api", version = "4.1.1" } | ||
|
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 used the
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. Should we instead rely on the Quarkus BOM for this to prevent conflict? i.e. we would import it as:
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. We never use
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. Yes sorry the 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 does bringing in the Quarkus BOM prevent conflict? As none of the places where I added the compile time dependency bring in Quarkus, what would it conflict with?
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. Compile-only deps have very little effect downstream, if I'm not mistaken. The only tricky situation I can imagine is when annotation packages or class names change... which is very unlikely for a mature library. I do not think pulling Quarkus into API modules is justified for that. During the server build, Quarkus will (should) bump all versions according to its platform deps anyway. However, we should probably have a Quarkus integration test that overrides the timeout to a low value and validates that requests do get cancelled. This should validate proper annotation handling (in case of class name changes). |
||
| mockito-core = { module = "org.mockito:mockito-core", version = "5.17.0" } | ||
| mockito-junit-jupiter = { module = "org.mockito:mockito-junit-jupiter", version = "5.17.0" } | ||
| opentelemetry-bom = { module = "io.opentelemetry:opentelemetry-bom", version = "1.49.0" } | ||
|
|
||
| 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") | ||
|
|
||
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.
nit: could you move this together with the other compile deps too?
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.
This is the only compile dep :))