Skip to content

Commit

Permalink
Release discarded pages in mutateInstance (elastic#100472)
Browse files Browse the repository at this point in the history
EsqlQueryResponseTests.testEqualsAndHashcode failed on CI because we did 
not release pages were discarded by randomValueOtherThan while mutating
the testing instance.
  • Loading branch information
dnhatn authored Oct 9, 2023
1 parent a12195c commit db4f92f
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.elasticsearch.compute.data.LongBlock;
import org.elasticsearch.compute.data.Page;
import org.elasticsearch.compute.lucene.UnsupportedValueSource;
import org.elasticsearch.core.Releasables;
import org.elasticsearch.test.AbstractChunkedSerializingTestCase;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.XContentType;
Expand Down Expand Up @@ -136,11 +137,12 @@ protected EsqlQueryResponse mutateInstance(EsqlQueryResponse instance) {
case 1 -> new EsqlQueryResponse(instance.columns(), deepCopyOfPages(instance), false == instance.columnar());
case 2 -> {
int noPages = instance.pages().size();
yield new EsqlQueryResponse(
instance.columns(),
randomValueOtherThan(instance.pages(), () -> randomList(noPages, noPages, () -> randomPage(instance.columns()))),
instance.columnar()
);
List<Page> differentPages = List.of();
do {
differentPages.forEach(p -> Releasables.closeExpectNoException(p::releaseBlocks));
differentPages = randomList(noPages, noPages, () -> randomPage(instance.columns()));
} while (differentPages.equals(instance.pages()));
yield new EsqlQueryResponse(instance.columns(), differentPages, instance.columnar());
}
default -> throw new IllegalArgumentException();
};
Expand Down

0 comments on commit db4f92f

Please sign in to comment.