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

feat(query-orchestrator): QueryQueue - reduce trafic for processing #7644

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export interface QueueDriverConnectionInterface {
release(): void;
//
getQueriesToCancel(): Promise<QueryKeysTuple[]>
// @deprecated
getActiveAndToProcess(): Promise<GetActiveAndToProcessResponse>;
}

Expand Down
35 changes: 7 additions & 28 deletions packages/cubejs-cubestore-driver/src/CubeStoreQueueDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,34 +136,13 @@ class CubestoreQueueDriverConnection implements QueueDriverConnectionInterface {
}

public async getActiveAndToProcess(): Promise<GetActiveAndToProcessResponse> {
const rows = await this.driver.query<CubeStoreListResponse>('QUEUE LIST ?', [
this.options.redisQueuePrefix
]);
if (rows.length) {
const active: QueryKeysTuple[] = [];
const toProcess: QueryKeysTuple[] = [];

for (const row of rows) {
if (row.status === 'active') {
active.push([
row.id as QueryKeyHash,
row.queue_id ? parseInt(row.queue_id, 10) : null,
]);
} else {
toProcess.push([
row.id as QueryKeyHash,
row.queue_id ? parseInt(row.queue_id, 10) : null,
]);
}
}

return [
active,
toProcess,
];
}

return [[], []];
return [
// We don't return active queries, because it's useless
// There is only one place where it's used, and it's QueryQueue.reconcileQueueImpl
// Cube Store provides strict guarantees that queue item cannot be active & pending in the same time
[],
await this.getToProcessQueries()
];
}

public async getNextProcessingId(): Promise<number | string> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,13 @@ export class QueryQueue {
}
}));

/**
* There is a bug somewhere in Redis (maybe in memory too?),
* which doesn't remove queue item from pending, while it's in active state
*
* TODO(ovr): Check LocalQueueDriver for strict guarantees that item cannot be in active & pending in the same time
* TODO(ovr): Migrate to getToProcessQueries after removal of Redis
*/
const [active, toProcess] = await queueConnection.getActiveAndToProcess();

await Promise.all(
Expand Down
Loading