Fix exception cause logging in QueryResultPusher #14975
Fix exception cause logging in QueryResultPusher #14975rohangarg merged 23 commits intoapache:masterfrom
Conversation
|
| if (!(e instanceof QueryException)) { | ||
| e = new QueryInterruptedException(e); | ||
| } | ||
| return DruidException.fromFailure(new QueryExceptionCompat((QueryException) e)); |
There was a problem hiding this comment.
(QueryException) is it safe cast?
There was a problem hiding this comment.
QueryInterruptedException extends QueryException. So should be good
There was a problem hiding this 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
| @Override | ||
| public void writeException(Exception e, OutputStream out) throws IOException | ||
| { | ||
| throw new RuntimeException("Unimplemented!"); |
There was a problem hiding this comment.
maybe just do a
out.write(jsonMapper.writeValueABytes(e))
here
There was a problem hiding this 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 :)
|
The
The correct approach to fix odd exception reporting here is to go to the source of the exception and turn it into a meaningful |
|
Also, the |
|
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. |
imply-cheddar
left a comment
There was a problem hiding this comment.
The actual change is good. Please try to remove the mocks from the test.
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.when; |
There was a problem hiding this 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).
There was a problem hiding this comment.
It was an interesting excercise to rewrite this test to use EasyMock instead; its definetly different.
| ObjectMapper jsonMapper = new ObjectMapper(); | ||
| ResponseContextConfig responseContextConfig = ResponseContextConfig.newConfig(true); | ||
| DruidNode selfNode = mock(DruidNode.class); | ||
| QueryResource.QueryMetricCounter counter = mock(QueryResource.QueryMetricCounter.class); |
There was a problem hiding this 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.
There was a problem hiding this 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
|
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 |
|
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 |
|
thank you @rohangarg for the review and merging these changes! |
QueryResultPusherstarted clipping exception causes since #14004 was mergedcfd07a9#diff-8af2383f47d5423babf455ad7ec503ea8196e88b8b664e1d1e179163a9931f9bR211