S3: Data read has a different checksum than expected

See original GitHub issue

This might be fixed by 472f5bfbce08038653b641b070e3ac09ae846313, but not sure. I also am seeing some errors where the response.contentLength() differs from the actual size again, so there might be a race condition again. This is using 2.1.4 + netty.

Caused by: software.amazon.awssdk.core.exception.SdkClientException: Data read has a different checksum than expected.
        at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:97)
        at software.amazon.awssdk.core.exception.SdkClientException.create(SdkClientException.java:39)
        at software.amazon.awssdk.services.s3.internal.handlers.AsyncChecksumValidationInterceptor.validatePutObjectChecksum(AsyncChecksumValidationInterceptor.java:105)
        at software.amazon.awssdk.services.s3.internal.handlers.AsyncChecksumValidationInterceptor.afterUnmarshalling(AsyncChecksumValidationInterceptor.java:91)
        at software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain.lambda$afterUnmarshalling$9(ExecutionInterceptorChain.java:152)
        at software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain.reverseForEach(ExecutionInterceptorChain.java:210)
        at software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain.afterUnmarshalling(ExecutionInterceptorChain.java:152)
        at software.amazon.awssdk.core.client.handler.BaseClientHandler.runAfterUnmarshallingInterceptors(BaseClientHandler.java:120)
        at software.amazon.awssdk.core.client.handler.BaseClientHandler.lambda$interceptorCalling$2(BaseClientHandler.java:133)
        at software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler.handle(AttachHttpMetadataResponseHandler.java:40)
        at software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler.handle(AttachHttpMetadataResponseHandler.java:28)
        at software.amazon.awssdk.core.internal.http.async.SyncResponseHandlerAdapter.lambda$prepare$0(SyncResponseHandlerAdapter.java:85)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:55 (24 by maintainers)

github_iconTop GitHub Comments

6reactions
pavellikincommented, Oct 21, 2020

Hi. Unfortunately, I am still able to reproduce the issue on the SDK version 2.15.11. I prepared a demo project to show the issue.

The project has 3 tests. First to upload ~100kB array with checksum validation. This is the only green test in the scope. Both other tests upload ~1mB array with and without checksum validation. In the test with checksum validation, I get mentioned “Data read has a different checksum than expected” error. Without checksum validation bytes are uploaded to s3 but they are different from the original byte array.

Looks like the packets still be reordered as @marc-christian-schulze mentioned.

6reactions
huchengmingcommented, May 30, 2019

FWIW, we’ve encountered this issue too when calling getObject, which was due to S3AsyncClient.clientConfiguration having a duplicated set of default interceptors.

Apparently there can’t be more than one AsyncChecksumValidationInterceptor in the chain, as it will remove the checksum part and break the second check, which is why all those exceptions were expecting 0.

In DefaultS3BaseClientBuilder, it calls finalizeServiceConfiguration when building the client:

ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory();
List<ExecutionInterceptor> interceptors = interceptorFactory
        .getInterceptors("software/amazon/awssdk/services/s3/execution.interceptors");
interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS));
return config.toBuilder().option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).build();

ClasspathInterceptorChainFactory.getInterceptors uses its classloader’s getResources to fetch a list of ExecutionInterceptor, and for some reason it returned duplicated set of interceptors.

This was verified in our side by calling

Collections.list(
    new ClasspathInterceptorChainFactory().getClass().getClassLoader()
          .getResources("software/amazon/awssdk/services/s3/execution.interceptors")
).forEach(System.out::println);

Which prints out two same lines.

Looks like it’s a not-so-common bug, we had our servlet running as ROOT webapp in tomcat, renaming ROOT to something else fixed it.

However I would suggest changing the behavior of ClasspathInterceptorChainFactory.createExecutionInterceptorsFromClasspath, to check for duplication before returning. @millems

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data read has a different length than the expected - Stack ...
This answer was wrote from the guy of AWS Hanson: Is it possible that the input stream that is specified in the request...
Read more >
New – Additional Checksum Algorithms for Amazon S3
Today I am happy to tell you about S3's new support for four checksum algorithms. It is now very easy for you to...
Read more >
software.amazon.awssdk.core.checksums.SdkChecksum ...
... read has a different checksum than expected. Was %d, but expected %d", computedChecksum, streamChecksumInt)).build(); } }. origin: aws/aws-sdk-java-v2 ...
Read more >
s3: data read has a different checksum than expected
Schedules a new transfer to upload data to Amazon S3. This method is non-blocking and returns immediately (i.e. before the upload has finished)....
Read more >
aws/aws-sdk-java-v2 - Gitter
Data read has a different checksum than expected. _. version of SDK: 2.5.0. Zoe Wang. @zoewangg. @brainstorm We have this planned but haven't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found