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

[Reporting] fix too_long_frame_exception by passing scroll_id in the request body #102972

Merged
merged 5 commits into from
Jun 30, 2021
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 @@ -324,6 +324,23 @@ it('uses the scrollId to page all the data', async () => {
const csvResult = await generateCsv.generateData();
expect(csvResult.warnings).toEqual([]);
expect(csvResult.content).toMatchSnapshot();

expect(mockDataClient.search).toHaveBeenCalledTimes(1);
expect(mockDataClient.search).toBeCalledWith(
{ params: { scroll: '30s', size: 500 } },
{ strategy: 'es' }
);

// `scroll` and `clearScroll` must be called with scroll ID in the post body!
expect(mockEsClient.asCurrentUser.scroll).toHaveBeenCalledTimes(9);
expect(mockEsClient.asCurrentUser.scroll).toHaveBeenCalledWith({
body: { scroll: '30s', scroll_id: 'awesome-scroll-hero' },
});

expect(mockEsClient.asCurrentUser.clearScroll).toHaveBeenCalledTimes(1);
expect(mockEsClient.asCurrentUser.clearScroll).toHaveBeenCalledWith({
body: { scroll_id: ['awesome-scroll-hero'] },
});
});

describe('fields from job.searchSource.getFields() (7.12 generated)', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ export class CsvGenerator {
this.logger.debug(`executing scroll request`);
const results = (
await this.clients.es.asCurrentUser.scroll({
scroll: scrollSettings.duration,
scroll_id: scrollId,
body: {
scroll: scrollSettings.duration,
scroll_id: scrollId,
},
})
).body as SearchResponse<unknown>;
return results;
Expand Down Expand Up @@ -387,7 +389,7 @@ export class CsvGenerator {
if (scrollId) {
this.logger.debug(`executing clearScroll request`);
try {
await this.clients.es.asCurrentUser.clearScroll({ scroll_id: [scrollId] });
await this.clients.es.asCurrentUser.clearScroll({ body: { scroll_id: [scrollId] } });
} catch (err) {
this.logger.error(err);
}
Expand Down
Loading