Skip to content

Commit e9c2a53

Browse files
authored
chore(query-orchestrator): Enhanced log message with renewCycle flag (#7275)
1 parent 4fe8d93 commit e9c2a53

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

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

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,10 @@ export class QueryCache {
702702
expireSecs,
703703
cacheKey,
704704
renewalThreshold,
705-
options,
705+
{
706+
...options,
707+
renewCycle: true
708+
},
706709
).catch(e => {
707710
if (!(e instanceof ContinueWaitError)) {
708711
this.logger('Error while renew cycle', {
@@ -727,6 +730,7 @@ export class QueryCache {
727730
useCsvQuery?: boolean,
728731
lambdaTypes?: TableStructure,
729732
persistent?: boolean,
733+
renewCycle?: boolean,
730734
}
731735
) {
732736
options = options || { dataSource: 'default' };
@@ -762,6 +766,7 @@ export class QueryCache {
762766
lambdaTypes: options.lambdaTypes,
763767
persistent: options.persistent,
764768
primaryQuery: true,
769+
renewCycle: options.renewCycle,
765770
}
766771
),
767772
refreshKeyValues: cacheKeyQueryResults,
@@ -837,11 +842,12 @@ export class QueryCache {
837842
lambdaTypes?: TableStructure,
838843
persistent?: boolean,
839844
primaryQuery?: boolean,
845+
renewCycle?: boolean,
840846
}
841847
) {
842848
const spanId = crypto.randomBytes(16).toString('hex');
843849
options = options || { dataSource: 'default' };
844-
const { renewalThreshold, primaryQuery } = options;
850+
const { renewalThreshold, primaryQuery, renewCycle } = options;
845851
const renewalKey = options.renewalKey && this.queryRedisKey(options.renewalKey);
846852
const redisKey = this.queryRedisKey(cacheKey);
847853
const fetchNew = () => (
@@ -865,7 +871,7 @@ export class QueryCache {
865871
.cacheDriver
866872
.set(redisKey, result, expiration)
867873
.then(({ bytes }) => {
868-
this.logger('Renewed', { cacheKey, requestId: options.requestId, spanId, primaryQuery });
874+
this.logger('Renewed', { cacheKey, requestId: options.requestId, spanId, primaryQuery, renewCycle });
869875
this.logger('Outgoing network usage', {
870876
service: 'cache',
871877
requestId: options.requestId,
@@ -877,7 +883,7 @@ export class QueryCache {
877883
});
878884
}).catch(e => {
879885
if (!(e instanceof ContinueWaitError)) {
880-
this.logger('Dropping Cache', { cacheKey, error: e.stack || e, requestId: options.requestId, spanId, primaryQuery });
886+
this.logger('Dropping Cache', { cacheKey, error: e.stack || e, requestId: options.requestId, spanId, primaryQuery, renewCycle });
881887
this.cacheDriver.remove(redisKey)
882888
.catch(err => this.logger('Error removing key', {
883889
cacheKey,
@@ -891,7 +897,7 @@ export class QueryCache {
891897
);
892898

893899
if (options.forceNoCache) {
894-
this.logger('Force no cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery });
900+
this.logger('Force no cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery, renewCycle });
895901
return fetchNew();
896902
}
897903

@@ -926,6 +932,7 @@ export class QueryCache {
926932
requestId: options.requestId,
927933
spanId,
928934
primaryQuery,
935+
renewCycle
929936
});
930937
res = inMemoryValue;
931938
}
@@ -949,6 +956,7 @@ export class QueryCache {
949956
requestId: options.requestId,
950957
spanId,
951958
primaryQuery,
959+
renewCycle
952960
});
953961
if (
954962
renewalKey && (
@@ -959,24 +967,24 @@ export class QueryCache {
959967
)
960968
) {
961969
if (options.waitForRenew) {
962-
this.logger('Waiting for renew', { cacheKey, renewalThreshold, requestId: options.requestId, spanId, primaryQuery });
970+
this.logger('Waiting for renew', { cacheKey, renewalThreshold, requestId: options.requestId, spanId, primaryQuery, renewCycle });
963971
return fetchNew();
964972
} else {
965-
this.logger('Renewing existing key', { cacheKey, renewalThreshold, requestId: options.requestId, spanId, primaryQuery });
973+
this.logger('Renewing existing key', { cacheKey, renewalThreshold, requestId: options.requestId, spanId, primaryQuery, renewCycle });
966974
fetchNew().catch(e => {
967975
if (!(e instanceof ContinueWaitError)) {
968-
this.logger('Error renewing', { cacheKey, error: e.stack || e, requestId: options.requestId, spanId, primaryQuery });
976+
this.logger('Error renewing', { cacheKey, error: e.stack || e, requestId: options.requestId, spanId, primaryQuery, renewCycle });
969977
}
970978
});
971979
}
972980
}
973-
this.logger('Using cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery });
981+
this.logger('Using cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery, renewCycle });
974982
if (options.useInMemory && renewedAgo + inMemoryCacheDisablePeriod <= renewalThreshold * 1000) {
975983
this.memoryCache.set(redisKey, parsedResult);
976984
}
977985
return parsedResult.result;
978986
} else {
979-
this.logger('Missing cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery });
987+
this.logger('Missing cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery, renewCycle });
980988
return fetchNew();
981989
}
982990
}

0 commit comments

Comments
 (0)