Skip to content

Fix S3RepositoryThirdPartyTests.testReadFromPositionLargerThanBlobLength#106466

Merged
tlrx merged 5 commits intoelastic:mainfrom
tlrx:2024/03/19/fix-s3-3rd-party-test
Mar 22, 2024
Merged

Fix S3RepositoryThirdPartyTests.testReadFromPositionLargerThanBlobLength#106466
tlrx merged 5 commits intoelastic:mainfrom
tlrx:2024/03/19/fix-s3-3rd-party-test

Conversation

@tlrx
Copy link
Copy Markdown
Member

@tlrx tlrx commented Mar 19, 2024

The test should use a random operation purpose that is not "Indices", otherwise S3RetryingInputStream retries up to Integer.MAX_VALUE times which causes the test suite to timeout.

Also fixes the progress in the retries log messages.

Closes #106457

The test should use a random operation purpose that is not "Indices",
otherwise S3RetryingInputStream retries up to Integer.MAX_VALUE times
which causes the test suite to timeout.

Also fixes the progress in the retries log messages.

Relates elastic#106457
@tlrx tlrx added >test Issues or PRs that are addressing/adding tests :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v8.14.0 labels Mar 19, 2024
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team. label Mar 19, 2024
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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it intentionally moved?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If the request fails, currentStreamFirstOffset is not updated and currentStreamProgress() reports an inaccurate number.

Copy link
Copy Markdown
Contributor

@idegtiarenko idegtiarenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for a quick fix!

@tlrx tlrx requested a review from DaveCTurner March 19, 2024 11:03
Copy link
Copy Markdown
Member

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think we shouldn't be retrying on a 416, regardless of the purpose. Could we try that instead.

@tlrx
Copy link
Copy Markdown
Member Author

tlrx commented Mar 19, 2024

I think we shouldn't be retrying on a 416, regardless of the purpose

I think you're right. I pushed some changes, let me know what you (both) think

Copy link
Copy Markdown
Member

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +261 to +263
var cause = exception.getRootCause();
assertThat(cause, instanceOf(AmazonS3Exception.class));
assertThat(((AmazonS3Exception) cause).getStatusCode(), equalTo(RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit/one-liner suggestion:

Suggested change
var cause = exception.getRootCause();
assertThat(cause, instanceOf(AmazonS3Exception.class));
assertThat(((AmazonS3Exception) cause).getStatusCode(), equalTo(RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus()));
assertThat(
asInstanceOf(AmazonS3Exception.class, exception.getRootCause()).getStatusCode(),
equalTo(RestStatus.REQUESTED_RANGE_NOT_SATISFIED.getStatus())
);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL, I pushed 42ab562

@tlrx tlrx merged commit d8fc877 into elastic:main Mar 22, 2024
@tlrx tlrx deleted the 2024/03/19/fix-s3-3rd-party-test branch March 22, 2024 11:06
@tlrx
Copy link
Copy Markdown
Member Author

tlrx commented Mar 22, 2024

Thanks both!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed Meta label for distributed team. >test Issues or PRs that are addressing/adding tests v8.14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] S3RepositoryThirdPartyTests testReadFromPositionLargerThanBlobLength failing

4 participants