Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Add logs for remote store metadata intermittent read failures #8628

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

import java.io.IOException;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.lucene.codecs.CodecUtil;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.store.ChecksumIndexInput;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
Expand All @@ -22,6 +26,8 @@
* @opensearch.internal
*/
public class VersionedCodecStreamWrapper<T> {
private static final Logger logger = LogManager.getLogger(VersionedCodecStreamWrapper.class);

// TODO This can be updated to hold a streamReadWriteHandlerFactory and get relevant handler based on the stream versions
private final IndexIOStreamHandler<T> indexIOStreamHandler;
private final int currentVersion;
Expand All @@ -46,10 +52,21 @@ public VersionedCodecStreamWrapper(IndexIOStreamHandler<T> indexIOStreamHandler,
* @return stream content parsed into {@link T}
*/
public T readStream(IndexInput indexInput) throws IOException {
CodecUtil.checksumEntireFile(indexInput);
int readStreamVersion = checkHeader(indexInput);
T content = getHandlerForVersion(readStreamVersion).readContent(indexInput);
return content;
logger.debug("Reading input stream [{}] of length - [{}]", indexInput.toString(), indexInput.length());
try {
CodecUtil.checksumEntireFile(indexInput);
int readStreamVersion = checkHeader(indexInput);
return getHandlerForVersion(readStreamVersion).readContent(indexInput);
} catch (CorruptIndexException cie) {
logger.error(
() -> new ParameterizedMessage(
"Error while validating header/footer for [{}]. Total data length [{}]",
indexInput.toString(),
indexInput.length()
)
);
throw cie;
}
}

/**
Expand Down