diff --git a/muted-tests.yml b/muted-tests.yml index f8f30b82530ad..2b2bfabccb6bd 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -378,9 +378,6 @@ tests: - class: org.elasticsearch.smoketest.MlWithSecurityIT method: test {yaml=ml/data_frame_analytics_cat_apis/Test cat data frame analytics single job with header} issue: https://github.com/elastic/elasticsearch/issues/125642 -- class: org.elasticsearch.repositories.blobstore.testkit.analyze.GCSRepositoryAnalysisRestIT - method: testRepositoryAnalysis - issue: https://github.com/elastic/elasticsearch/issues/125668 - class: org.elasticsearch.packaging.test.DockerTests method: test010Install issue: https://github.com/elastic/elasticsearch/issues/125680 diff --git a/server/src/main/java/org/elasticsearch/common/blobstore/support/BlobContainerUtils.java b/server/src/main/java/org/elasticsearch/common/blobstore/support/BlobContainerUtils.java index 8bf18770fd031..dc757a2559bdf 100644 --- a/server/src/main/java/org/elasticsearch/common/blobstore/support/BlobContainerUtils.java +++ b/server/src/main/java/org/elasticsearch/common/blobstore/support/BlobContainerUtils.java @@ -9,10 +9,16 @@ package org.elasticsearch.common.blobstore.support; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.elasticsearch.common.ReferenceDocs; import org.elasticsearch.common.Strings; import org.elasticsearch.common.blobstore.BlobContainer; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.ChunkedLoggingStream; +import org.elasticsearch.common.unit.ByteSizeUnit; import java.io.IOException; import java.io.InputStream; @@ -32,6 +38,8 @@ public static void ensureValidRegisterContent(BytesReference bytesReference) { } } + private static final Logger logger = LogManager.getLogger(BlobContainerUtils.class); + /** * Many blob stores have consistent (linearizable/atomic) read semantics and in these casees it is safe to implement {@link * BlobContainer#getRegister} by simply reading the blob using this utility. @@ -51,7 +59,28 @@ public static BytesReference getRegisterUsingConsistentRead(InputStream inputStr len -= read; pos += read; } - if (inputStream.read() != -1) { + final int nextByte = inputStream.read(); + if (nextByte != -1) { + try ( + var cls = ChunkedLoggingStream.create( + logger, + Level.ERROR, + "getRegisterUsingConsistentRead including trailing data", + ReferenceDocs.LOGGING + ) + ) { + cls.write(bytes); + cls.write(nextByte); + final var buffer = new byte[ByteSizeUnit.KB.toIntBytes(1)]; + while (true) { + final var readSize = inputStream.read(buffer); + if (readSize == -1) { + break; + } + cls.write(buffer, 0, readSize); + } + } + throw new IllegalStateException( Strings.format("[%s] failed reading register [%s] due to unexpected trailing data", container, key) );