Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-10587

Reset the thread-local MessageDigest instance during exception

    XMLWordPrintableJSON

Details

    Description

      Currently, the MessageDigest instance is a thread local variable (one per S3G Jetty thread). MessageDigest requires the call to either MessageDigest#digest or MessageDigest#reset to reset the digest.

      In normal ObjectEndpoint#put flow, MessageDigest#digest is called after the data has been written to the datanodes, before the key is committed. However, if an IOException happens (e.g. EOFException due to client cancelling during the write), the digest will not be reset and remains in the inconsistent state. This will affect the subsequent request that uses the same thread and therefore the ETag generated will be completely different from the md5 hash of the object causing AWS S3 SDK to detect inconsistent hash when downloading the object.

      The issue can be replicated using an S3G with a single thread and doing three put-object operations for the same key and same payload. 

      1st put-object: cancel the operation before it put-object operation can finish, ensure the EOFException is thrown in the S3Gateway logs

      2nd put-object: let the put-object finish. The resulting ETag will not be the same as the md5 digest of the payload.

      3rd put-object: also let the put-object finish. Since the previous put-object reset the digest, the resulting ETag will be correct.

      This patch adds a call to MessageDigest#reset in ObjectEndpoint#put to reset the digest in case of exception.

      Attachments

        Issue Links

          Activity

            People

              ivanandika Ivan Andika
              ivanandika Ivan Andika
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: