mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Shard query splitting: stop querying on failure (#96284)
Shard query splitting: stop querying on final errors
This commit is contained in:
parent
e9956f2345
commit
01d2376782
@ -18,6 +18,10 @@ jest.mock('uuid', () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const originalShardingFlagState = config.featureToggles.lokiShardSplitting;
|
const originalShardingFlagState = config.featureToggles.lokiShardSplitting;
|
||||||
|
const originalErr = console.error;
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
});
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
jest.spyOn(global, 'setTimeout').mockImplementation((callback) => {
|
jest.spyOn(global, 'setTimeout').mockImplementation((callback) => {
|
||||||
@ -28,6 +32,7 @@ beforeAll(() => {
|
|||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
jest.mocked(global.setTimeout).mockReset();
|
jest.mocked(global.setTimeout).mockReset();
|
||||||
config.featureToggles.lokiShardSplitting = originalShardingFlagState;
|
config.featureToggles.lokiShardSplitting = originalShardingFlagState;
|
||||||
|
console.error = originalErr;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('runSplitQuery()', () => {
|
describe('runSplitQuery()', () => {
|
||||||
|
@ -138,9 +138,9 @@ export function isRetriableError(errorResponse: DataQueryResponse) {
|
|||||||
: (errorResponse.error?.message ?? '');
|
: (errorResponse.error?.message ?? '');
|
||||||
if (message.includes('timeout')) {
|
if (message.includes('timeout')) {
|
||||||
return true;
|
return true;
|
||||||
} else if (message.includes('parse error')) {
|
} else if (errorResponse.data.length > 0 && errorResponse.data[0].fields.length > 0) {
|
||||||
// If the error is a parse error, we want to signal to stop querying.
|
// Error response but we're receiving data, continue querying.
|
||||||
throw new Error(message);
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ jest.mock('uuid', () => ({
|
|||||||
|
|
||||||
const originalLog = console.log;
|
const originalLog = console.log;
|
||||||
const originalWarn = console.warn;
|
const originalWarn = console.warn;
|
||||||
|
const originalErr = console.error;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.spyOn(console, 'log').mockImplementation(() => {});
|
jest.spyOn(console, 'log').mockImplementation(() => {});
|
||||||
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
||||||
@ -22,6 +23,7 @@ beforeEach(() => {
|
|||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
console.log = originalLog;
|
console.log = originalLog;
|
||||||
console.warn = originalWarn;
|
console.warn = originalWarn;
|
||||||
|
console.error = originalErr;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('runShardSplitQuery()', () => {
|
describe('runShardSplitQuery()', () => {
|
||||||
@ -203,7 +205,7 @@ describe('runShardSplitQuery()', () => {
|
|||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
await expect(runShardSplitQuery(datasource, request)).toEmitValuesWith((response: DataQueryResponse[]) => {
|
await expect(runShardSplitQuery(datasource, request)).toEmitValuesWith((response: DataQueryResponse[]) => {
|
||||||
expect(datasource.runQuery).toHaveBeenCalledTimes(2);
|
expect(datasource.runQuery).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user