FrankChen021 commented on code in PR #20268:
URL: https://github.com/apache/druid/pull/20268#discussion_r3940813437
##########
server/src/main/java/org/apache/druid/server/initialization/jetty/JettyServerModule.java:
##########
@@ -404,6 +404,9 @@ public void lifeCycleStopped(LifeCycle event)
JettyServerInitializer initializer =
injector.getInstance(JettyServerInitializer.class);
try {
initializer.initialize(server, injector);
+ if (config.isEnableResponseIdentityHeaders()) {
+ server.setHandler(new ResponseIdentityHeaderHandler(node,
server.getHandler()));
Review Comment:
[P2] Cover Jetty-generated errors outside the handler
This wrapper only runs after Jetty has parsed the request and entered the
application handler. Jetty creates a temporary ChannelResponse for
request-line/header parse failures and uses its own error-response path, which
clears response headers without passing through this wrapper. Malformed or
oversized requests therefore return without the identity triple even though the
docs promise headers on every response, including early errors. Install the
identity at the connector/error-response path or add equivalent coverage there.
##########
services/src/main/java/org/apache/druid/server/AsyncQueryForwardingServlet.java:
##########
@@ -634,6 +635,10 @@ protected void onServerResponseHeaders(
if (responseContext != null) {
proxyResponse.setHeader(responseContext.getName(),
responseContext.getValue());
}
+ // When response identity headers are enabled, the outer response handler
initially adds the Router identity.
+ // An upstream response must replace it with the upstream identity, or
with no identity when the upstream does not
+ // provide a complete header triple.
+ ResponseIdentityHeaderHandler.clearRouterIdentity(proxyResponse);
Review Comment:
[P2] Restore Router identity on proxy failure
After upstream headers arrive, this clears the Router triple. If the
upstream then fails before the downstream response commits, Jetty's inherited
onProxyResponseFailure calls resetBuffer(), which preserves headers, and
sendError() to generate the Router's 502/504. The final Router-generated error
consequently either carries the upstream identity or, for a partial upstream
triple, no identity at all. Restore the Router triple in that failure path;
apply the same handling to the management and Coordinator-to-Overlord proxies.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]