# S3 Retry Behavior

**URL:** <https://discuss.elastic.co/t/s3-retry-behavior/372781>\
**Category:** Elastic Search\
**Created:** [January 3, 2025, 10:57pm UTC](https://discuss.elastic.co/t/s3-retry-behavior/372781 "2025-01-03T22:57:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rliao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rliao/32/140462_2.png) [@rliao](https://discuss.elastic.co/u/rliao)\
**Post date:** [January 3, 2025, 10:57pm UTC](https://discuss.elastic.co/t/s3-retry-behavior/372781/1 "2025-01-03T22:57:54Z")

</div>

Hi,

We are testing Elasticsearch with a third party S3 compatible object store per the analyze API and had a question regarding retry behavior. We found this snippet in S3RetryingInputStream.java:

```auto
            try (AmazonS3Reference clientReference = blobStore.clientReference()) {
                final GetObjectRequest getObjectRequest = new GetObjectRequest(blobStore.bucket(), blobKey);
                configureRequestForMetrics(getObjectRequest, blobStore, Operation.GET_OBJECT, purpose);
                if (currentOffset > 0 || start > 0 || end < Long.MAX_VALUE - 1) {
                    assert start + currentOffset <= end
                        : "requesting beyond end, start = " + start + " offset=" + currentOffset + " end=" + end;
                    getObjectRequest.setRange(Math.addExact(start, currentOffset), end);
                }
                this.currentStreamFirstOffset = Math.addExact(start, currentOffset);
                final S3Object s3Object = SocketAccess.doPrivileged(() -> clientReference.client().getObject(getObjectRequest));
                this.currentStreamLastOffset = Math.addExact(currentStreamFirstOffset, getStreamLength(s3Object));
                this.currentStream = s3Object.getObjectContent();
                return;

```

This snippet suggests that an offset is maintained within Elasticsearch to retry the GetObjectRequest. However, it is not guaranteed that the object's contents would be the same on a subsequent retry given the lack of preconditions (e.g. If-Match/If-Modified-Since). This seems like it could mix data from an older object and a new object that was written during the fetch by S3RetryingInputStream.

Is there something else in Elasticsearch that would ensure a consistent view of the object here?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 31, 2025, 10:58pm UTC](https://discuss.elastic.co/t/s3-retry-behavior/372781/2 "2025-01-31T22:58:18Z")

</div>

Closed on January 31, 2025, 10:58pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
