Fix failures in ShuffleForcedMergePolicyTests#testDiagnostics (#48627)
This commit fixes intermittent failures in ShuffleForcedMergePolicyTests#testDiagnostics by setting a more restricted merge policy that ensures that extra merging will not happen before the forced merge.
This commit is contained in:
parent
a0362153e2
commit
aa70ff5ea4
|
@ -77,7 +77,7 @@ public class ShuffleForcedMergePolicy extends FilterMergePolicy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMergeInfo(SegmentCommitInfo info) {
|
public void setMergeInfo(SegmentCommitInfo info) {
|
||||||
// Record that this merged segment is current as of this schemaGen:
|
// record that this segment was merged with interleaved segments
|
||||||
Map<String, String> copy = new HashMap<>(info.info.getDiagnostics());
|
Map<String, String> copy = new HashMap<>(info.info.getDiagnostics());
|
||||||
copy.put(SHUFFLE_MERGE_KEY, "");
|
copy.put(SHUFFLE_MERGE_KEY, "");
|
||||||
info.info.setDiagnostics(copy);
|
info.info.setDiagnostics(copy);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ShuffleForcedMergePolicyTests extends BaseMergePolicyTestCase {
|
||||||
public void testDiagnostics() throws IOException {
|
public void testDiagnostics() throws IOException {
|
||||||
try (Directory dir = newDirectory()) {
|
try (Directory dir = newDirectory()) {
|
||||||
IndexWriterConfig iwc = newIndexWriterConfig();
|
IndexWriterConfig iwc = newIndexWriterConfig();
|
||||||
MergePolicy mp = new ShuffleForcedMergePolicy(newLogMergePolicy());
|
MergePolicy mp = new ShuffleForcedMergePolicy(newTieredMergePolicy());
|
||||||
iwc.setMergePolicy(mp);
|
iwc.setMergePolicy(mp);
|
||||||
boolean sorted = random().nextBoolean();
|
boolean sorted = random().nextBoolean();
|
||||||
if (sorted) {
|
if (sorted) {
|
||||||
|
@ -57,16 +57,12 @@ public class ShuffleForcedMergePolicyTests extends BaseMergePolicyTestCase {
|
||||||
}
|
}
|
||||||
try (DirectoryReader reader = DirectoryReader.open(writer)) {
|
try (DirectoryReader reader = DirectoryReader.open(writer)) {
|
||||||
assertThat(reader.leaves().size(), greaterThan(2));
|
assertThat(reader.leaves().size(), greaterThan(2));
|
||||||
assertSegmentReaders(reader, leaf -> {
|
assertSegmentReaders(reader, leaf -> assertFalse(ShuffleForcedMergePolicy.isInterleavedSegment(leaf)));
|
||||||
assertFalse(ShuffleForcedMergePolicy.isInterleavedSegment(leaf));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
writer.forceMerge(1);
|
writer.forceMerge(1);
|
||||||
try (DirectoryReader reader = DirectoryReader.open(writer)) {
|
try (DirectoryReader reader = DirectoryReader.open(writer)) {
|
||||||
assertThat(reader.leaves().size(), equalTo(1));
|
assertThat(reader.leaves().size(), equalTo(1));
|
||||||
assertSegmentReaders(reader, leaf -> {
|
assertSegmentReaders(reader, leaf -> assertTrue(ShuffleForcedMergePolicy.isInterleavedSegment(leaf)));
|
||||||
assertTrue(ShuffleForcedMergePolicy.isInterleavedSegment(leaf));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,8 +80,10 @@ public class ShuffleForcedMergePolicyTests extends BaseMergePolicyTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void assertSegmentInfos(MergePolicy policy, SegmentInfos infos) throws IOException {}
|
protected void assertSegmentInfos(MergePolicy policy, SegmentInfos infos) throws IOException {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void assertMerge(MergePolicy policy, MergePolicy.MergeSpecification merge) throws IOException {}
|
protected void assertMerge(MergePolicy policy, MergePolicy.MergeSpecification merge) throws IOException {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue