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 request timeout annotation #4499
implement request timeout annotation #4499
Conversation
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.
❔ Some questions along the way:
(tests are to come)
...n/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeoutDecoratorFunction.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeout.java
Show resolved
Hide resolved
...n/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeoutDecoratorFunction.java
Outdated
Show resolved
Hide resolved
...n/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeoutDecoratorFunction.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeout.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeout.java
Show resolved
Hide resolved
...n/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeoutDecoratorFunction.java
Outdated
Show resolved
Hide resolved
0dae8e4
to
c171bcf
Compare
Sorry for the late update 😅 🙏 private void setTimeoutNanosFromStart(long timeoutNanos) {
checkArgument(timeoutNanos >= 0, "timeoutNanos: %s (expected: >= 0)", timeoutNanos);
if (timeoutNanos == 0) {
clearTimeout();
return;
}
if (isInitialized()) {
if (eventLoop.inEventLoop()) {
setTimeoutNanosFromStart0(timeoutNanos);
} else {
eventLoop.execute(() -> setTimeoutNanosFromStart0(timeoutNanos));
}
} else {
addPendingTimeoutNanos(timeoutNanos);
addPendingTask(() -> setTimeoutNanosFromStart0(timeoutNanos));
}
} CancellationScheduler$setTimeoutNanosFromStart seems to do a saturated add with the default request timeout in |
I forget noting armeria/grpc/src/main/java/com/linecorp/armeria/server/grpc/FramedGrpcService.java Lines 228 to 246 in 49054ad
It would not make sense if the timeout is updated by the client header after |
It sounds like a bug. We should use
In fact, |
Codecov ReportBase: 74.08% // Head: 74.07% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #4499 +/- ##
============================================
- Coverage 74.08% 74.07% -0.01%
+ Complexity 18185 18183 -2
============================================
Files 1537 1538 +1
Lines 67469 67475 +6
Branches 8537 8537
============================================
- Hits 49987 49985 -2
+ Misses 13419 13414 -5
- Partials 4063 4076 +13
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
4fb6c86
to
53ed701
Compare
I've looked in to more of armeria's requestTimeout implementation, and confirmed that service.serve() before requestCancellationScheduler.init() is called. scheduler initialization occurs on AggregatedHttpResponseHandler construction, which happens at the end of HttpServerHandler$handleRequest.
|
as for this issue, it seems somehow wrong that the client could override the request timeout causing the call to last longer than the time set on the server-side, not just for |
- Add @interface RequestTimeout - Add RequestTimeoutDecoratorFunction
f18a446
to
e47426d
Compare
https://github.com/line/armeria/actions/runs/3525487381/jobs/5912289404#step:7:1181 |
@minwoox You're right, it's a testcase to show that there's an issue with the current request timeout implementation. How would you suggest to fix it?
this seems to be the cause of the issue |
Do you mean
That is fair enough. 👍 |
...n/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeoutDecoratorFunction.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/common/CancellationScheduler.java
Show resolved
Hide resolved
@minwoox |
Thanks! Now I got it. 😄 |
It makes sense. The contract of armeria/grpc/src/main/java/com/linecorp/armeria/server/grpc/GrpcServiceBuilder.java Lines 789 to 796 in c888c86
For simplicity, I prefer to apply either |
.../test/java/com/linecorp/armeria/internal/server/annotation/RequestTimeoutAnnotationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/com/linecorp/armeria/internal/server/annotation/RequestTimeoutAnnotationTest.java
Outdated
Show resolved
Hide resolved
...n/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeoutDecoratorFunction.java
Outdated
Show resolved
Hide resolved
Ah, I see. I though't that if the servicecode is run before timeout is initialized, the actual timeout applied could be longer than desired. But if that was intended, we could ignore it. I'll remove the failing testcase
I'll revert changes in 71aeac2 and add the additional documentation to |
This reverts commit 71aeac2.
I completely forgot that we have
Yes, it was. 😄 Thanks! |
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.
Thanks, @j-min5u! 💯❤️
.../test/java/com/linecorp/armeria/internal/server/annotation/RequestTimeoutAnnotationTest.java
Outdated
Show resolved
Hide resolved
.../test/java/com/linecorp/armeria/internal/server/annotation/RequestTimeoutAnnotationTest.java
Outdated
Show resolved
Hide resolved
...n/java/com/linecorp/armeria/server/annotation/decorator/RequestTimeoutDecoratorFunction.java
Outdated
Show resolved
Hide resolved
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.
👍 👍 👍
Thaaaaanks again. 😄 |
Motivation:
Provide a way to set a request timeout using annotation
Modifications:
Result: