Skip to content

Commit f4af922

Browse files
fix: do not retry requests by user (#1059)
1 parent 7b9adda commit f4af922

File tree

8 files changed

+35
-54
lines changed

8 files changed

+35
-54
lines changed

src/services/api.ts

+19-42
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ import type {TNetInfo} from '../types/api/netInfo';
1818
import type {TNodesInfo} from '../types/api/nodes';
1919
import type {TEvNodesInfo} from '../types/api/nodesList';
2020
import type {TEvPDiskStateResponse, TPDiskInfoResponse} from '../types/api/pdisk';
21-
import type {
22-
Actions,
23-
ErrorResponse,
24-
ExplainActions,
25-
ExplainResponse,
26-
QueryAPIResponse,
27-
Schemas,
28-
} from '../types/api/query';
21+
import type {Actions, ErrorResponse, QueryAPIResponse, Schemas} from '../types/api/query';
2922
import type {JsonRenderRequestParams, JsonRenderResponse} from '../types/api/render';
3023
import type {RestartPDiskResponse} from '../types/api/restartPDisk';
3124
import type {TEvDescribeSchemeResult} from '../types/api/schema';
@@ -53,14 +46,17 @@ import {settingsManager} from './settings';
5346
type AxiosOptions = {
5447
concurrentId?: string;
5548
signal?: AbortSignal;
49+
withRetries?: boolean;
5650
};
5751

5852
export class YdbEmbeddedAPI extends AxiosWrapper {
53+
DEFAULT_RETRIES_COUNT = 3;
54+
5955
constructor(options?: AxiosWrapperOptions) {
6056
super(options);
6157

6258
axiosRetry(this._axios, {
63-
retries: 3,
59+
retries: this.DEFAULT_RETRIES_COUNT,
6460
retryDelay: axiosRetry.exponentialDelay,
6561
});
6662

@@ -442,7 +438,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
442438
schema?: Schema;
443439
syntax?: QuerySyntax;
444440
},
445-
{concurrentId, signal}: AxiosOptions = {},
441+
{concurrentId, signal, withRetries}: AxiosOptions = {},
446442
) {
447443
// Time difference to ensure that timeout from ui will be shown rather than backend error
448444
const uiTimeout = 9 * 60 * 1000;
@@ -468,38 +464,11 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
468464
{
469465
concurrentId,
470466
timeout: uiTimeout,
471-
requestConfig: {signal},
472-
},
473-
);
474-
}
475-
getExplainQuery<Action extends ExplainActions>(
476-
query: string,
477-
database: string,
478-
action: Action,
479-
syntax?: QuerySyntax,
480-
) {
481-
return this.post<ExplainResponse<Action> | ErrorResponse>(
482-
this.getPath('/viewer/json/query'),
483-
{
484-
query,
485-
database,
486-
action: action || 'explain',
487-
syntax,
488-
timeout: 600000,
489-
},
490-
{},
491-
);
492-
}
493-
getExplainQueryAst(query: string, database: string) {
494-
return this.post<ExplainResponse<'explain-ast'>>(
495-
this.getPath('/viewer/json/query'),
496-
{
497-
query,
498-
database,
499-
action: 'explain-ast',
500-
timeout: 600000,
467+
requestConfig: {
468+
signal,
469+
'axios-retry': {retries: withRetries ? this.DEFAULT_RETRIES_COUNT : 0},
470+
},
501471
},
502-
{},
503472
);
504473
}
505474
getHotKeys(
@@ -562,6 +531,7 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
562531
// Automatic headers may not suit
563532
Accept: 'application/json',
564533
},
534+
requestConfig: {'axios-retry': {retries: 0}},
565535
},
566536
);
567537
}
@@ -580,22 +550,29 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
580550
headers: {
581551
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
582552
},
553+
requestConfig: {'axios-retry': {retries: 0}},
583554
},
584555
);
585556
}
586557
killTablet(id?: string) {
587-
return this.get<string>(this.getPath(`/tablets?KillTabletID=${id}`), {});
558+
return this.get<string>(
559+
this.getPath(`/tablets?KillTabletID=${id}`),
560+
{},
561+
{requestConfig: {'axios-retry': {retries: 0}}},
562+
);
588563
}
589564
stopTablet(id?: string, hiveId?: string) {
590565
return this.get<string>(
591566
this.getPath(`/tablets/app?TabletID=${hiveId}&page=StopTablet&tablet=${id}`),
592567
{},
568+
{requestConfig: {'axios-retry': {retries: 0}}},
593569
);
594570
}
595571
resumeTablet(id?: string, hiveId?: string) {
596572
return this.get<string>(
597573
this.getPath(`/tablets/app?TabletID=${hiveId}&page=ResumeTablet&tablet=${id}`),
598574
{},
575+
{requestConfig: {'axios-retry': {retries: 0}}},
599576
);
600577
}
601578
getTabletDescribe(tenantId: TDomainKey, {concurrentId, signal}: AxiosOptions = {}) {

src/store/reducers/executeTopQueries/executeTopQueries.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const topQueriesApi = api.injectEndpoints({
6262
database,
6363
action: 'execute-scan',
6464
},
65-
{signal},
65+
{signal, withRetries: true},
6666
);
6767

6868
if (isQueryErrorResponse(response)) {

src/store/reducers/explainQuery/explainQuery.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export const explainQueryApi = api.injectEndpoints({
2525
}
2626

2727
try {
28-
const response = await window.api.getExplainQuery(
28+
const response = await window.api.sendQuery({
2929
query,
3030
database,
3131
action,
3232
syntax,
33-
);
33+
});
3434

3535
if (isQueryErrorResponse(response)) {
3636
return {error: response};

src/store/reducers/preview.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const previewApi = api.injectEndpoints({
1616
try {
1717
const response = await window.api.sendQuery(
1818
{schema: 'modern', query, database, action},
19-
{signal},
19+
{signal, withRetries: true},
2020
);
2121

2222
if (isQueryErrorResponse(response)) {

src/store/reducers/shardsWorkload/shardsWorkload.ts

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ export const shardApi = api.injectEndpoints({
148148
},
149149
{
150150
signal,
151+
withRetries: true,
151152
},
152153
);
153154

src/store/reducers/tenantOverview/executeTopTables/executeTopTables.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const topTablesApi = api.injectEndpoints({
2525
database: path,
2626
action: 'execute-scan',
2727
},
28-
{signal},
28+
{signal, withRetries: true},
2929
);
3030

3131
if (isQueryErrorResponse(response)) {

src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const topShardsApi = api.injectEndpoints({
3333
database,
3434
action: queryAction,
3535
},
36-
{signal},
36+
{signal, withRetries: true},
3737
);
3838

3939
if (isQueryErrorResponse(response)) {

src/store/reducers/viewSchema/viewSchema.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ export const viewSchemaApi = api.injectEndpoints({
1010
getViewSchema: build.query({
1111
queryFn: async ({database, path}: {database: string; path: string}) => {
1212
try {
13-
const response = await window.api.sendQuery({
14-
schema: 'modern',
15-
query: createViewSchemaQuery(path),
16-
database,
17-
action: 'execute-scan',
18-
});
13+
const response = await window.api.sendQuery(
14+
{
15+
schema: 'modern',
16+
query: createViewSchemaQuery(path),
17+
database,
18+
action: 'execute-scan',
19+
},
20+
{withRetries: true},
21+
);
1922

2023
if (isQueryErrorResponse(response)) {
2124
return {error: response};

0 commit comments

Comments
 (0)