Skip to content

Commit 50025aa

Browse files
committed
clean up obsolete
1 parent cb33bfc commit 50025aa

File tree

3 files changed

+2
-77
lines changed

3 files changed

+2
-77
lines changed

packages/cubejs-query-orchestrator/src/orchestrator/QueryCache.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export class QueryCache {
300300
);
301301
}
302302

303-
if (!this.options.backgroundRenew) {
303+
if (!this.options.backgroundRenew && queryBody.cacheMode !== 'stale-while-revalidate') {
304304
const resultPromise = this.renewQuery(
305305
query,
306306
values,
@@ -760,42 +760,6 @@ export class QueryCache {
760760
});
761761
}
762762

763-
public async startBackgroundRefreshForQuery(queryBody: QueryBody, preAggregationsTablesToTempTables: PreAggTableToTempTable[]) {
764-
const replacePreAggregationTableNames =
765-
(queryAndParams: string | QueryWithParams) => (
766-
QueryCache.replacePreAggregationTableNames(
767-
queryAndParams,
768-
preAggregationsTablesToTempTables,
769-
)
770-
);
771-
772-
const query = replacePreAggregationTableNames(queryBody.query);
773-
const { values } = queryBody;
774-
775-
const cacheKeyQueries = this
776-
.cacheKeyQueriesFrom(queryBody)
777-
.map(replacePreAggregationTableNames);
778-
779-
const renewalThreshold = queryBody.cacheKeyQueries?.renewalThreshold;
780-
const expireSecs = this.getExpireSecs(queryBody);
781-
const cacheKey = QueryCache.queryCacheKey(queryBody);
782-
783-
this.startRenewCycle(
784-
query,
785-
values,
786-
cacheKeyQueries,
787-
expireSecs,
788-
cacheKey,
789-
renewalThreshold,
790-
{
791-
external: queryBody.external,
792-
requestId: queryBody.requestId,
793-
dataSource: queryBody.dataSource,
794-
persistent: false, // We don't need stream back as there will be no consumer
795-
}
796-
);
797-
}
798-
799763
public renewQuery(
800764
query: string | QueryWithParams,
801765
values: string[],

packages/cubejs-query-orchestrator/src/orchestrator/QueryOrchestrator.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -143,29 +143,6 @@ export class QueryOrchestrator {
143143
return this.preAggregations;
144144
}
145145

146-
/**
147-
* Starts background refresh cycle for a query.
148-
*/
149-
public async startBackgroundRefresh(queryBody: QueryBody): Promise<void> {
150-
if (!queryBody.query) {
151-
return;
152-
}
153-
154-
const {
155-
preAggregationsTablesToTempTables,
156-
values,
157-
} = await this.preAggregations.loadAllPreAggregationsIfNeeded(queryBody);
158-
159-
if (values) {
160-
queryBody = {
161-
...queryBody,
162-
values
163-
};
164-
}
165-
166-
await this.queryCache.startBackgroundRefreshForQuery(queryBody, preAggregationsTablesToTempTables);
167-
}
168-
169146
/**
170147
* Force reconcile queue logic to be executed.
171148
*/

packages/cubejs-server-core/src/core/OrchestratorApi.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export class OrchestratorApi {
140140
.orchestrator
141141
.resultFromCacheIfExists(query);
142142

143-
if (query.cacheMode === 'stale-if-slow' && fromCache) {
143+
if ((query.cacheMode === 'stale-if-slow' || query.cacheMode === 'stale-while-revalidate') && fromCache) {
144144
this.logger('Slow Query Warning', {
145145
query: queryForLog,
146146
requestId: query.requestId,
@@ -155,22 +155,6 @@ export class OrchestratorApi {
155155
};
156156
}
157157

158-
if (query.cacheMode === 'stale-while-revalidate' && fromCache) {
159-
// Start background refresh
160-
this.orchestrator.startBackgroundRefresh(query).catch(e => {
161-
this.logger('Error starting background refresh', {
162-
query: queryForLog,
163-
requestId: query.requestId,
164-
error: ((e as Error).stack || e)
165-
});
166-
});
167-
168-
return {
169-
...fromCache,
170-
slowQuery: true
171-
};
172-
}
173-
174158
throw {
175159
error: 'Continue wait',
176160
stage: await this.orchestrator.queryStage(query)

0 commit comments

Comments
 (0)