aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

JsonContent logging transient errors at INFO

Open samhendley opened this issue 9 years ago • 11 comments

We are seeing this error intermittently with our kinesis consumer (1.7.4) which is using SDK 1.11.91.

[2017-03-29 14:50:27,212] INFO Unable to parse HTTP response content (com.amazonaws.protocol.json.JsonContent:74)
com.fasterxml.jackson.core.JsonParseException: Illegal length for VALUE_STRING: 2477946696968059424
 at [Source: [B@bbc6ebd; line: -1, column: 9]
        at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1581)
        at com.fasterxml.jackson.dataformat.cbor.CBORParser._decodeExplicitLength(CBORParser.java:2612)
        at com.fasterxml.jackson.dataformat.cbor.CBORParser._finishTextToken(CBORParser.java:1787)
        at com.fasterxml.jackson.dataformat.cbor.CBORParser.getText(CBORParser.java:1203)
        at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeAny(JsonNodeDeserializer.java:316)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:73)
        at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:15)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3736)
        at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2294)
        at com.amazonaws.protocol.json.JsonContent.parseJsonContent(JsonContent.java:72)
        at com.amazonaws.protocol.json.JsonContent.<init>(JsonContent.java:64)
        at com.amazonaws.protocol.json.JsonContent.createJsonContent(JsonContent.java:54)
        at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:61)
        at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:33)
        at com.amazonaws.http.AwsErrorResponseHandler.handleAse(AwsErrorResponseHandler.java:50)
        at com.amazonaws.http.AwsErrorResponseHandler.handle(AwsErrorResponseHandler.java:38)
        at com.amazonaws.http.AwsErrorResponseHandler.handle(AwsErrorResponseHandler.java:24)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1561)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1249)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1030)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:742)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:716)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
        at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
        at com.amazonaws.services.kinesis.AmazonKinesisClient.doInvoke(AmazonKinesisClient.java:1831)
        at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:1807)
        at com.amazonaws.services.kinesis.AmazonKinesisClient.getRecords(AmazonKinesisClient.java:912)
        at com.amazonaws.services.kinesis.clientlibrary.proxies.KinesisProxy.get(KinesisProxy.java:156)
        at com.amazonaws.services.kinesis.clientlibrary.proxies.MetricsCollectingKinesisProxyDecorator.get(MetricsCollectingKinesisProxyDecorator.java:74)
        at com.amazonaws.services.kinesis.clientlibrary.lib.worker.KinesisDataFetcher.getRecords(KinesisDataFetcher.java:68)
        at com.amazonaws.services.kinesis.clientlibrary.lib.worker.ProcessTask.getRecordsResultAndRecordMillisBehindLatest(ProcessTask.java:371)
        at com.amazonaws.services.kinesis.clientlibrary.lib.worker.ProcessTask.getRecordsResult(ProcessTask.java:336)
        at com.amazonaws.services.kinesis.clientlibrary.lib.worker.ProcessTask.call(ProcessTask.java:153)
        at com.amazonaws.services.kinesis.clientlibrary.lib.worker.MetricsCollectingTaskDecorator.call(MetricsCollectingTaskDecorator.java:49)
        at com.amazonaws.services.kinesis.clientlibrary.lib.worker.MetricsCollectingTaskDecorator.call(MetricsCollectingTaskDecorator.java:24)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

This error only occurs once or twice a day and as such has been difficult to get to occur with the wire level tracing. Clearly there is some sort of transient error occuring but it doesn't seem to affect the behavior of the application. This leads me to believe that the logging is at too high of a level or exception shouldn't be getting caught at that level at all. As you can see the stack trace is already in an error handler and has a number of exception handlers to deal with "unparsable errors". None of those get to fire because JsonContent catches the exceptions. My feeling is that it shouldn't be catching these exceptions at all but there may be other cases where this code is used that makes this harder to handle.

This is not the first issue where errors have been reported with this block of code. (#969 #930 #820 ) If we can't fix the behavior can we at least log the payload that failed to be parsed so we more quickly determine the cause of the problem. Something like the below would help dramatically:

private static JsonNode parseJsonContent(byte[] rawJsonContent, ObjectMapper mapper) {
        if (rawJsonContent == null) {
            return mapper.createObjectNode();
        }
        try {
            return mapper.readTree(rawJsonContent);
        } catch (Exception e) {
            LOG.info("Unable to parse HTTP response content", e);
///////////////
            LOG.debug("Unable to parse HTTP response content from " + new String(rawJsonContent), e);
///////////////
            return mapper.createObjectNode();
        }
    }

samhendley avatar Apr 07 '17 12:04 samhendley

I have been seeing the same error, but my application is inserting to Kinesis Streams. Like @samhendley says this is an intermittent error that pop ups every 3 days odd.

emilianork avatar Jun 05 '17 16:06 emilianork

I'm coming here because of KinesisStream driver issue too.

Issue obviously is starting from code

AmazonHttpClient#executeHelper

Response<Output> response = executeOneRequest(execOneParams);

Seems more of a Kinesis endpoint issue., but agree with original issue raiser, SDK should log the exact response thats causing parse failure.

prayagupa avatar Jun 13 '17 22:06 prayagupa

Same issue here. +1 to have more detailed information about the error.

fabriziofortino avatar Jun 30 '17 14:06 fabriziofortino

We are seeing same issue. From above I cant tell if there has been a resolution.

kayvank avatar Jul 21 '17 14:07 kayvank

See same issue:

com.fasterxml.jackson.core.JsonParseException: Illegal length for VALUE_STRING: 2477946696968059424
 at [Source: [B@4c024c31; line: -1, column: 9]
	at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
	at com.fasterxml.jackson.dataformat.cbor.CBORParser._decodeExplicitLength(CBORParser.java:2785)
	at com.fasterxml.jackson.dataformat.cbor.CBORParser._finishTextToken(CBORParser.java:1959)
	at com.fasterxml.jackson.dataformat.cbor.CBORParser.getText(CBORParser.java:1353)
	at com.fasterxml.jackson.databind.deser.std.BaseNodeDeserializer.deserializeAny(JsonNodeDeserializer.java:317)
	at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:73)
	at com.fasterxml.jackson.databind.deser.std.JsonNodeDeserializer.deserialize(JsonNodeDeserializer.java:15)
	at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3798)
	at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:2404)
	at com.amazonaws.protocol.json.JsonContent.parseJsonContent(JsonContent.java:72)
	at com.amazonaws.protocol.json.JsonContent.<init>(JsonContent.java:64)
	at com.amazonaws.protocol.json.JsonContent.createJsonContent(JsonContent.java:54)
	at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:61)
	at com.amazonaws.http.JsonErrorResponseHandler.handle(JsonErrorResponseHandler.java:33)
	at com.amazonaws.http.AwsErrorResponseHandler.handleAse(AwsErrorResponseHandler.java:50)
	at com.amazonaws.http.AwsErrorResponseHandler.handle(AwsErrorResponseHandler.java:38)
	at com.amazonaws.http.AwsErrorResponseHandler.handle(AwsErrorResponseHandler.java:24)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleErrorResponse(AmazonHttpClient.java:1570)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeOneRequest(AmazonHttpClient.java:1258)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1030)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:742)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:716)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:699)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:667)
	at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:649)
	at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:513)
	at com.amazonaws.services.kinesis.AmazonKinesisClient.doInvoke(AmazonKinesisClient.java:1831)
	at com.amazonaws.services.kinesis.AmazonKinesisClient.invoke(AmazonKinesisClient.java:1807)
	at com.amazonaws.services.kinesis.AmazonKinesisClient.putRecords(AmazonKinesisClient.java:1529)

Our SDK version is 1.11.91

Jackyjjc avatar Aug 23 '17 00:08 Jackyjjc

hi @Jackyjjc it turns out that this exceptions are SDK level. The SDK by default will retry 3 more times to push the record to kniesis. If the retries succeeds, no such exceptions within 1-3 seconds, then you could ignore them.

kayvank avatar Aug 23 '17 00:08 kayvank

Apologies for the lack of response, would someone like to volunteer to troubleshoot this issue? We'd need to capture some wire logs and request IDs to find out if the issue is in the SDK or on the service side. If anyone experiencing this issue is interested in helping debug please let me know.

shorea avatar Sep 19 '17 19:09 shorea

Same issue here with @plorenzatto

pablodo avatar Sep 27 '17 20:09 pablodo

@pablodo would you be able to capture AmazonServiceException.getRawResponse() when this happens.

shorea avatar Sep 27 '17 20:09 shorea

We aren't able to reproduce this on our end. Feel free to reopen with more information or logs if it continues to be a problem for you.

millems avatar Oct 03 '17 21:10 millems

BTW, decimal 2477946696968059424 in hex is 22636F6465223A20, which is the 8 ASCII character (last character is a space) string "code":

jgoehringer avatar Nov 10 '17 16:11 jgoehringer