Skip to content

Fix test failures related to file corruption #36530

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

Merged
merged 2 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
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 @@ -475,7 +475,6 @@ public void testCorruptionOnNetworkLayer() throws ExecutionException, Interrupte
* TODO once checksum verification on snapshotting is implemented this test needs to be fixed or split into several
* parts... We should also corrupt files on the actual snapshot and check that we don't restore the corrupted shard.
*/
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/36526")
public void testCorruptFileThenSnapshotAndRestore() throws ExecutionException, InterruptedException, IOException {
int numDocs = scaledRandomIntBetween(100, 1000);
internalCluster().ensureAtLeastNumDataNodes(2);
Expand Down Expand Up @@ -676,7 +675,10 @@ private static boolean isPerSegmentFile(String fileName) {
private void pruneOldDeleteGenerations(Set<Path> files) {
final TreeSet<Path> delFiles = new TreeSet<>();
for (Path file : files) {
if (file.getFileName().toString().endsWith(".liv")) {
if (file.getFileName().toString().endsWith(".liv")
|| file.getFileName().toString().endsWith(".dvm")
|| file.getFileName().toString().endsWith(".dvd")
) {
delFiles.add(file);
}
}
Expand All @@ -685,17 +687,9 @@ private void pruneOldDeleteGenerations(Set<Path> files) {
if (last != null) {
final String newSegmentName = IndexFileNames.parseSegmentName(current.getFileName().toString());
final String oldSegmentName = IndexFileNames.parseSegmentName(last.getFileName().toString());
if (newSegmentName.equals(oldSegmentName)) {
int oldGen =
Integer.parseInt(
IndexFileNames.stripExtension(
IndexFileNames.stripSegmentName(last.getFileName().toString())).replace("_", ""),
Character.MAX_RADIX
);
int newGen = Integer.parseInt(
IndexFileNames.stripExtension(
IndexFileNames.stripSegmentName(current.getFileName().toString())).replace("_", ""),
Character.MAX_RADIX);
if (newSegmentName.equals(oldSegmentName) ) {
long oldGen = IndexFileNames.parseGeneration(last.getFileName().toString());
long newGen = IndexFileNames.parseGeneration(current.getFileName().toString());
if (newGen > oldGen) {
files.remove(last);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ public static void corruptFile(Random random, Path... files) throws IOException

long checksumAfterCorruption;
long actualChecksumAfterCorruption;

try (ChecksumIndexInput input = dir.openChecksumInput(fileToCorrupt.getFileName().toString(), IOContext.DEFAULT)) {
assertThat(input.getFilePointer(), is(0L));
input.seek(input.length() - 8); // one long is the checksum... 8 bytes
input.seek(input.length() - CodecUtil.footerLength());
checksumAfterCorruption = input.getChecksum();
input.seek(input.length() - 8);
actualChecksumAfterCorruption = input.readLong();
}
// we need to add assumptions here that the checksums actually really don't match there is a small chance to get collisions
Expand Down