Skip to content
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
14 changes: 7 additions & 7 deletions packages/cubejs-base-driver/src/queue-driver.interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type QueryDef = unknown;
// Primary key of Queue item
export type QueueId = string | number | bigint;
// This was used as lock for Redis, deprecated.
export type ProcessingId = string | number;
// This was used as a lock for Redis, deprecated.
export type ProcessingId = string | number | bigint;
export type QueryKey = (string | [string, any[]]) & {
persistent?: true,
};
Expand Down Expand Up @@ -64,25 +64,25 @@ export interface QueueDriverConnectionInterface {
* @param keyScore Redis specific thing
* @param queryKey
* @param orphanedTime
* @param queryHandler Our queue allow to use different handlers. For example query, cvsQuery, etc.
* @param queryHandler Our queue allows using different handlers. For example, query, cvsQuery, etc.
* @param query
* @param priority
* @param options
*/
addToQueue(keyScore: number, queryKey: QueryKey, orphanedTime: number, queryHandler: string, query: AddToQueueQuery, priority: number, options: AddToQueueOptions): Promise<AddToQueueResponse>;
// Return query keys which was sorted by priority and time
// Return query keys that were sorted by priority and time
getToProcessQueries(): Promise<QueryKeysTuple[]>;
getActiveQueries(): Promise<QueryKeysTuple[]>;
getQueryDef(hash: QueryKeyHash, queueId: QueueId | null): Promise<QueryDef | null>;
// Queries which was added to queue, but was not processed and not needed
// Queries that were added to queue, but was not processed and not needed
getOrphanedQueries(): Promise<QueryKeysTuple[]>;
// Queries which was not completed with old heartbeat
// Queries that were not completed with old heartbeat
getStalledQueries(): Promise<QueryKeysTuple[]>;
getQueryStageState(onlyKeys: boolean): Promise<QueryStageStateResponse>;
updateHeartBeat(hash: QueryKeyHash, queueId: QueueId | null): Promise<void>;
getNextProcessingId(): Promise<ProcessingId>;
// Trying to acquire a lock for processing a queue item, this method can return null when
// multiple nodes tries to process the same query
// multiple nodes try to process the same query
retrieveForProcessing(hash: QueryKeyHash, processingId: ProcessingId): Promise<RetrieveForProcessingResponse>;
freeProcessingLock(hash: QueryKeyHash, processingId: ProcessingId, activated: unknown): Promise<void>;
optimisticQueryUpdate(hash: QueryKeyHash, toUpdate: unknown, processingId: ProcessingId, queueId: QueueId | null): Promise<boolean>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ export class QueryQueue {
queryProcessHeartbeat = Date.now();
}

return queueConnection.updateHeartBeat(queryKeyHashed);
return queueConnection.updateHeartBeat(queryKeyHashed, queueId);
Copy link
Member Author

@ovr ovr Jul 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cube Store allows updating the heartbeat by path or QueueId. Using QueueId provides better performance and fixes possible concurrency issues such as slippage

},
this.heartBeatInterval * 1000
);
Expand Down
Loading