Skip to content

Commit eb3d980

Browse files
authored
fix(query-orchestrator): Fix dropping temp tables during pre-agg creation (#9295)
1 parent 1c8ce4f commit eb3d980

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ export class PreAggregationLoader {
618618
dropSourceTempTable: boolean,
619619
) {
620620
if (withTempTable && dropSourceTempTable) {
621-
await this.withDropLock(false, async () => {
621+
await this.withDropLock(`drop-temp-table:${this.preAggregation.dataSource}:${targetTableName}`, async () => {
622622
this.logger('Dropping source temp table', queryOptions);
623623

624624
const actualTables = await client.getTablesQuery(this.preAggregation.preAggregationsSchema);
@@ -965,8 +965,7 @@ export class PreAggregationLoader {
965965
});
966966
}
967967

968-
private async withDropLock<T>(external: boolean, lockFn: () => MaybeCancelablePromise<T>): Promise<boolean> {
969-
const lockKey = this.dropLockKey(external);
968+
private async withDropLock<T>(lockKey: string, lockFn: () => MaybeCancelablePromise<T>): Promise<boolean> {
970969
return this.queryCache.withLock(lockKey, 60 * 5, lockFn);
971970
}
972971

@@ -979,7 +978,7 @@ export class PreAggregationLoader {
979978
) {
980979
await this.preAggregations.addTableUsed(justCreatedTable);
981980

982-
return this.withDropLock(external, async () => {
981+
return this.withDropLock(this.dropOrphanedLockKey(external), async () => {
983982
this.logger('Dropping orphaned tables', { ...queryOptions, external });
984983
const actualTables = await client.getTablesQuery(
985984
this.preAggregation.preAggregationsSchema,
@@ -1039,7 +1038,7 @@ export class PreAggregationLoader {
10391038
});
10401039
}
10411040

1042-
private dropLockKey(external: boolean) {
1041+
private dropOrphanedLockKey(external: boolean) {
10431042
return external
10441043
? 'drop-orphaned-tables-external'
10451044
: `drop-orphaned-tables:${this.preAggregation.dataSource}`;

0 commit comments

Comments
 (0)