Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(query-orchestrator): Enhanced log message with renewCycle flag information #7275

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions packages/cubejs-query-orchestrator/src/orchestrator/QueryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,10 @@
expireSecs,
cacheKey,
renewalThreshold,
options,
{
...options,
renewCycle: true
},
).catch(e => {
if (!(e instanceof ContinueWaitError)) {
this.logger('Error while renew cycle', {
Expand All @@ -727,6 +730,7 @@
useCsvQuery?: boolean,
lambdaTypes?: TableStructure,
persistent?: boolean,
renewCycle?: boolean,
}
) {
options = options || { dataSource: 'default' };
Expand Down Expand Up @@ -762,6 +766,7 @@
lambdaTypes: options.lambdaTypes,
persistent: options.persistent,
primaryQuery: true,
renewCycle: options.renewCycle,
}
),
refreshKeyValues: cacheKeyQueryResults,
Expand Down Expand Up @@ -837,11 +842,12 @@
lambdaTypes?: TableStructure,
persistent?: boolean,
primaryQuery?: boolean,
renewCycle?: boolean,
}
) {
const spanId = crypto.randomBytes(16).toString('hex');
options = options || { dataSource: 'default' };
const { renewalThreshold, primaryQuery } = options;
const { renewalThreshold, primaryQuery, renewCycle } = options;
const renewalKey = options.renewalKey && this.queryRedisKey(options.renewalKey);
const redisKey = this.queryRedisKey(cacheKey);
const fetchNew = () => (
Expand All @@ -865,7 +871,7 @@
.cacheDriver
.set(redisKey, result, expiration)
.then(({ bytes }) => {
this.logger('Renewed', { cacheKey, requestId: options.requestId, spanId, primaryQuery });
this.logger('Renewed', { cacheKey, requestId: options.requestId, spanId, primaryQuery, renewCycle });
this.logger('Outgoing network usage', {
service: 'cache',
requestId: options.requestId,
Expand All @@ -877,7 +883,7 @@
});
}).catch(e => {
if (!(e instanceof ContinueWaitError)) {
this.logger('Dropping Cache', { cacheKey, error: e.stack || e, requestId: options.requestId, spanId, primaryQuery });
this.logger('Dropping Cache', { cacheKey, error: e.stack || e, requestId: options.requestId, spanId, primaryQuery, renewCycle });
this.cacheDriver.remove(redisKey)
.catch(err => this.logger('Error removing key', {
cacheKey,
Expand All @@ -891,7 +897,7 @@
);

if (options.forceNoCache) {
this.logger('Force no cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery });
this.logger('Force no cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery, renewCycle });

Check warning on line 900 in packages/cubejs-query-orchestrator/src/orchestrator/QueryCache.ts

View check run for this annotation

Codecov / codecov/patch

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

Added line #L900 was not covered by tests
return fetchNew();
}

Expand Down Expand Up @@ -926,6 +932,7 @@
requestId: options.requestId,
spanId,
primaryQuery,
renewCycle
});
res = inMemoryValue;
}
Expand All @@ -949,6 +956,7 @@
requestId: options.requestId,
spanId,
primaryQuery,
renewCycle
});
if (
renewalKey && (
Expand All @@ -959,24 +967,24 @@
)
) {
if (options.waitForRenew) {
this.logger('Waiting for renew', { cacheKey, renewalThreshold, requestId: options.requestId, spanId, primaryQuery });
this.logger('Waiting for renew', { cacheKey, renewalThreshold, requestId: options.requestId, spanId, primaryQuery, renewCycle });
return fetchNew();
} else {
this.logger('Renewing existing key', { cacheKey, renewalThreshold, requestId: options.requestId, spanId, primaryQuery });
this.logger('Renewing existing key', { cacheKey, renewalThreshold, requestId: options.requestId, spanId, primaryQuery, renewCycle });
fetchNew().catch(e => {
if (!(e instanceof ContinueWaitError)) {
this.logger('Error renewing', { cacheKey, error: e.stack || e, requestId: options.requestId, spanId, primaryQuery });
this.logger('Error renewing', { cacheKey, error: e.stack || e, requestId: options.requestId, spanId, primaryQuery, renewCycle });
}
});
}
}
this.logger('Using cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery });
this.logger('Using cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery, renewCycle });
if (options.useInMemory && renewedAgo + inMemoryCacheDisablePeriod <= renewalThreshold * 1000) {
this.memoryCache.set(redisKey, parsedResult);
}
return parsedResult.result;
} else {
this.logger('Missing cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery });
this.logger('Missing cache for', { cacheKey, requestId: options.requestId, spanId, primaryQuery, renewCycle });
return fetchNew();
}
}
Expand Down
Loading