You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "kgyrtkirk (via GitHub)" <gi...@apache.org> on 2023/09/13 17:17:30 UTC

[PR] Fix exception cause logging in QueryResultPusher (druid)

kgyrtkirk opened a new pull request, #14975:
URL: https://github.com/apache/druid/pull/14975

   `QueryResultPusher` started clipping exception causes since #14004  was merged
   
   https://github.com/apache/druid/commit/cfd07a95b7d592a333ca51597e9bbdd68e18a88a#diff-8af2383f47d5423babf455ad7ec503ea8196e88b8b664e1d1e179163a9931f9bR211


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "imply-cheddar (via GitHub)" <gi...@apache.org>.
imply-cheddar commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1325914741


##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();

Review Comment:
   `new DefaultObjectMapper();` is generally better.  It includes various configs that we use and some default serde stuff.



##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);

Review Comment:
   There is a `MockHttpServletRequest` that you can `new` up instead.



##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);

Review Comment:
   Just make a local `public static class NoopQueryMetricCounter` and new that up.  Your IDE should be able to generate it all with just a few keystrokes.



##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);
+    String queryId = "someQuery";
+    MediaType contentType = mock(MediaType.class);

Review Comment:
   `MediaType.APPLICATION_JSON_TYPE`???  Can just grab anything really.



##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;

Review Comment:
   Generally speaking, we try to use mocks sparingly.  And, Mockito is the less-preferred of libraries versus EasyMock (we had a test once that used Mockito to mock a `ByteBuffer` which 4x'd the runtime of all tests because it ended up rewriting the byte code of `ByteBuffer` which slowed down all other tests in that JVM).



##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);
+    String queryId = "someQuery";
+    MediaType contentType = mock(MediaType.class);
+    Map<String, String> extraHeaders = new HashMap<String, String>();
+
+    ResultsWriter resultWriter = mock(ResultsWriter.class);

Review Comment:
   Can just create a local anonymous-inner-class that throws the exception out of the accumulate call.  And returns an actual fake QueryResponse object.



##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);
+    String queryId = "someQuery";
+    MediaType contentType = mock(MediaType.class);
+    Map<String, String> extraHeaders = new HashMap<String, String>();
+
+    ResultsWriter resultWriter = mock(ResultsWriter.class);
+    @SuppressWarnings("unchecked")
+    List<Exception> loggedExceptions = mock(List.class);

Review Comment:
   This seems like it would make sense as just an ArrayList?



##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);

Review Comment:
   I understand that there are lots of constructor parameters, but this object is `new`-able.  One pattern we follow sometimes when we get tired of using all of those parameters is to have a `TestDruidNode` or a `TestDruidNodeBuilder` that can be used to simplify the building of it.



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1325574378


##########
server/src/main/java/org/apache/druid/server/QueryResultPusher.java:
##########
@@ -278,6 +274,17 @@ private Response handleDruidException(ResultsWriter resultsWriter, DruidExceptio
     }
   }
 
+  private DruidException toDruidException(Exception e)
+  {
+    if (e instanceof DruidException) {
+      return (DruidException) e;
+    }
+    if (!(e instanceof QueryException)) {
+      e = new QueryInterruptedException(e);
+    }
+    return DruidException.fromFailure(new QueryExceptionCompat((QueryException) e));

Review Comment:
   yes - actually; I've changed the way this is fixed
   
   I now think that it was not intentional that `QueryExceptionCompat` have not passed the `exception`  ; only it's message
   
   cc: @cheddar 



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "rohangarg (via GitHub)" <gi...@apache.org>.
rohangarg commented on PR #14975:
URL: https://github.com/apache/druid/pull/14975#issuecomment-1727412990

   The changes are good, the CI failures are due to some flakiness in the ITs. We re-triggered them multiple times but were unsuccessful in getting them passed. Merging on the basis that the build was green on a commit earlier, the newer commits are either changes to UTs which wouldn't affect the IT flow or master merges


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1326126045


##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);
+    String queryId = "someQuery";
+    MediaType contentType = mock(MediaType.class);
+    Map<String, String> extraHeaders = new HashMap<String, String>();
+
+    ResultsWriter resultWriter = mock(ResultsWriter.class);

Review Comment:
   I was capturing the `resultWriter.recordFailure()` call ; but change it to handle it in a local `ResultWriter` class



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1324943043


##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);
+    String queryId = "someQuery";
+    MediaType contentType = null;
+    Map<String, String> extraHeaders = new HashMap<String, String>();
+
+    ResultsWriter resultWriter = mock(ResultsWriter.class);
+
+    QueryResultPusher pusher = new QueryResultPusher(
+        request,
+        jsonMapper,
+        responseContextConfig,
+        selfNode,
+        counter,
+        queryId,
+        contentType,
+        extraHeaders)
+    {
+
+      @Override
+      public void writeException(Exception e, OutputStream out) throws IOException
+      {
+        throw new RuntimeException("Unimplemented!");

Review Comment:
   maybe just do a
   `
   out.write(jsonMapper.writeValueABytes(e)) 
   `
   here



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1324934788


##########
server/src/main/java/org/apache/druid/server/QueryResultPusher.java:
##########
@@ -278,6 +274,17 @@ private Response handleDruidException(ResultsWriter resultsWriter, DruidExceptio
     }
   }
 
+  private DruidException toDruidException(Exception e)
+  {
+    if (e instanceof DruidException) {
+      return (DruidException) e;
+    }
+    if (!(e instanceof QueryException)) {
+      e = new QueryInterruptedException(e);
+    }
+    return DruidException.fromFailure(new QueryExceptionCompat((QueryException) e));

Review Comment:
    QueryInterruptedException extends QueryException. So should be good



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "imply-cheddar (via GitHub)" <gi...@apache.org>.
imply-cheddar commented on PR #14975:
URL: https://github.com/apache/druid/pull/14975#issuecomment-1719229821

   Also, the `ResultPusher` classes are tested "through" `QueryResourceTest` and `SqlQueryResourceTest` respectively.  `QueryResultPusher` is an abstract class that's just trying to make the logic of the `Resources` similar, but the thing that actually matters is that the Resources are operating according to the API contract.  Anyway, switching around to trying to test through one of those tests will perhaps make it easier.


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "pranavbhole (via GitHub)" <gi...@apache.org>.
pranavbhole commented on PR #14975:
URL: https://github.com/apache/druid/pull/14975#issuecomment-1718056255

   ```
   org.apache.druid.error.DruidException: null
   	at org.apache.druid.error.DruidException$DruidExceptionBuilder.build(DruidException.java:454) ~[druid-processing-2023.08.0-iap.jar:2023.08.0-iap]
   	at org.apache.druid.error.DruidException$DruidExceptionBuilder.build(DruidException.java:444) ~[druid-processing-2023.08.0-iap.jar:2023.08.0-iap]
   	at org.apache.druid.error.QueryExceptionCompat.makeException(QueryExceptionCompat.java:50) ~[druid-processing-2023.08.0-iap.jar:2023.08.0-iap]
   	at org.apache.druid.error.DruidException.fromFailure(DruidException.java:154) ~[druid-processing-2023.08.0-iap.jar:2023.08.0-iap]
   	at org.apache.druid.server.QueryResultPusher.handleQueryException(QueryResultPusher.java:211) ~[druid-server-2023.08.0-iap.jar:2023.08.0-iap]
   	at org.apache.druid.server.QueryResultPusher.push(QueryResultPusher.java:177) ~[druid-server-2023.08.0-iap.jar:2023.08.0-iap]
   	at org.apache.druid.server.QueryResource.doPost(QueryResource.java:218) ~[druid-server-2023.08.0-iap.jar:2023.08.0-iap]
   	at jdk.internal.reflect.GeneratedMethodAccessor207.invoke(Unknown Source) ~[?:?]
   	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
   	at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
   	at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108) ~[jersey-server-1.19.4.jar:1.19.4]
   	at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147) ~[jersey-server-1.19.4.jar:1.19.4]
   	at 


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "pranavbhole (via GitHub)" <gi...@apache.org>.
pranavbhole commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1324891129


##########
server/src/main/java/org/apache/druid/server/QueryResultPusher.java:
##########
@@ -278,6 +274,17 @@ private Response handleDruidException(ResultsWriter resultsWriter, DruidExceptio
     }
   }
 
+  private DruidException toDruidException(Exception e)
+  {
+    if (e instanceof DruidException) {
+      return (DruidException) e;
+    }
+    if (!(e instanceof QueryException)) {
+      e = new QueryInterruptedException(e);
+    }
+    return DruidException.fromFailure(new QueryExceptionCompat((QueryException) e));

Review Comment:
   (QueryException) is it safe cast? 



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on PR #14975:
URL: https://github.com/apache/druid/pull/14975#issuecomment-1727417110

   thank you @rohangarg for the review and merging these changes!


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1325571136


##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);
+    String queryId = "someQuery";
+    MediaType contentType = null;
+    Map<String, String> extraHeaders = new HashMap<String, String>();
+
+    ResultsWriter resultWriter = mock(ResultsWriter.class);
+
+    QueryResultPusher pusher = new QueryResultPusher(
+        request,
+        jsonMapper,
+        responseContextConfig,
+        selfNode,
+        counter,
+        queryId,
+        contentType,
+        extraHeaders)
+    {
+
+      @Override
+      public void writeException(Exception e, OutputStream out) throws IOException
+      {
+        throw new RuntimeException("Unimplemented!");

Review Comment:
   the test was not covering this method - as it was already pretty awkward to write a mocked test for this class...
   
   I've extended the test to cover this method as well... I had to add 4 when-s/etc :)



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "imply-cheddar (via GitHub)" <gi...@apache.org>.
imply-cheddar commented on PR #14975:
URL: https://github.com/apache/druid/pull/14975#issuecomment-1719402104

   That said, I just double checked and adding the cause shouldn't actually change anything with wire serialization.  So that should be fine and having it log-able is good.  Let me provide some comments on the tests.


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1326088579


##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;

Review Comment:
   It was an interesting excercise to rewrite this test to use `EasyMock` instead; its definetly different.
   



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1326091387


##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);

Review Comment:
   all implementations of `QueryMetricCounter` are private - so I had to retain the `mock` here



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "imply-cheddar (via GitHub)" <gi...@apache.org>.
imply-cheddar commented on PR #14975:
URL: https://github.com/apache/druid/pull/14975#issuecomment-1719226826

   The `QueryCompat` stuff is a compatibility layer with the way that the old `QueryException` worked and an attempt to map it onto `DruidException`.
   
   `QueryException`s are/were exceptions that are serialized across the wire, deserialized in the brokers and then converted back into exceptions.  IIRC, they don't include the stack traces because the historical-side stacktrace doesn't make sense on the broker.
   
   The correct approach to fix odd exception reporting here is to go to the source of the exception and turn it into a meaningful `DruidException` which will cause the higher stacks to use the `DruidException` handling code instead.


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "rohangarg (via GitHub)" <gi...@apache.org>.
rohangarg merged PR #14975:
URL: https://github.com/apache/druid/pull/14975


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "somu-imply (via GitHub)" <gi...@apache.org>.
somu-imply commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1324943043


##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);
+    String queryId = "someQuery";
+    MediaType contentType = null;
+    Map<String, String> extraHeaders = new HashMap<String, String>();
+
+    ResultsWriter resultWriter = mock(ResultsWriter.class);
+
+    QueryResultPusher pusher = new QueryResultPusher(
+        request,
+        jsonMapper,
+        responseContextConfig,
+        selfNode,
+        counter,
+        queryId,
+        contentType,
+        extraHeaders)
+    {
+
+      @Override
+      public void writeException(Exception e, OutputStream out) throws IOException
+      {
+        throw new RuntimeException("Unimplemented!");

Review Comment:
   maybe just do a
   `
   out.write() 
   `
   here



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on code in PR #14975:
URL: https://github.com/apache/druid/pull/14975#discussion_r1326091387


##########
server/src/test/java/org/apache/druid/server/QueryResultPusherTest.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.server;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.base.Throwables;
+import org.apache.druid.java.util.common.guava.Sequence;
+import org.apache.druid.server.QueryResultPusher.ResultsWriter;
+import org.junit.Test;
+
+import javax.servlet.AsyncContext;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class QueryResultPusherTest
+{
+  @Test
+  public void testResultPusherRetainsNestedExceptionBacktraces()
+  {
+    HttpServletRequest request = mock(HttpServletRequest.class);
+    ObjectMapper jsonMapper = new ObjectMapper();
+    ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true);
+    DruidNode selfNode = mock(DruidNode.class);
+    QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class);

Review Comment:
   all implementations of `QueryMetricCounter` are private - so I had to retain the `mock` here
   there is `SqlResource.QUERY_METRIC_COUNTER` ; but that's in the `sql` module; so I can't use that here



-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix exception cause logging in QueryResultPusher (druid)

Posted by "kgyrtkirk (via GitHub)" <gi...@apache.org>.
kgyrtkirk commented on PR #14975:
URL: https://github.com/apache/druid/pull/14975#issuecomment-1720890707

   I've also done a manual before/after check - to see if this fully fixes that the Exception is not clipped out from the historical logs - and that's fixed with this patch (no more ducks eating exceptions) :D 


-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org