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 originalErr = console.error;
|
||||
beforeEach(() => {
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
});
|
||||
beforeAll(() => {
|
||||
// @ts-expect-error
|
||||
jest.spyOn(global, 'setTimeout').mockImplementation((callback) => {
|
||||
@ -28,6 +32,7 @@ beforeAll(() => {
|
||||
afterAll(() => {
|
||||
jest.mocked(global.setTimeout).mockReset();
|
||||
config.featureToggles.lokiShardSplitting = originalShardingFlagState;
|
||||
console.error = originalErr;
|
||||
});
|
||||
|
||||
describe('runSplitQuery()', () => {
|
||||
|
@ -138,9 +138,9 @@ export function isRetriableError(errorResponse: DataQueryResponse) {
|
||||
: (errorResponse.error?.message ?? '');
|
||||
if (message.includes('timeout')) {
|
||||
return true;
|
||||
} else if (message.includes('parse error')) {
|
||||
// If the error is a parse error, we want to signal to stop querying.
|
||||
throw new Error(message);
|
||||
} else if (errorResponse.data.length > 0 && errorResponse.data[0].fields.length > 0) {
|
||||
// Error response but we're receiving data, continue querying.
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
throw new Error(message);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ jest.mock('uuid', () => ({
|
||||
|
||||
const originalLog = console.log;
|
||||
const originalWarn = console.warn;
|
||||
const originalErr = console.error;
|
||||
beforeEach(() => {
|
||||
jest.spyOn(console, 'log').mockImplementation(() => {});
|
||||
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
||||
@ -22,6 +23,7 @@ beforeEach(() => {
|
||||
afterAll(() => {
|
||||
console.log = originalLog;
|
||||
console.warn = originalWarn;
|
||||
console.error = originalErr;
|
||||
});
|
||||
|
||||
describe('runShardSplitQuery()', () => {
|
||||
@ -203,7 +205,7 @@ describe('runShardSplitQuery()', () => {
|
||||
callback();
|
||||
});
|
||||
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