cube-js/cube · error
Pre-aggregation table is not found for ${this.preAggregation
Error message
Pre-aggregation table is not found for ${this.preAggregation.tableName} after it was successfully created What it means
After a pre-aggregation build was reported successful, mostRecentResult resets the load cache and re-fetches version entries expecting to find the last content version. If none is found, the newly created table cannot be located, so it throws. This is a consistency check: the build succeeded but the version/table lookup disagrees, typically due to cache/staleness or concurrent modifications.
Source
Thrown at packages/cubejs-query-orchestrator/src/orchestrator/PreAggregationLoader.ts:277
const versionEntry =
versionEntries.byStructure[`${this.preAggregation.tableName}_${structureVersion}`] ||
versionEntries.byTableName[this.preAggregation.tableName];
const newVersionEntry: VersionEntry = {
table_name: this.preAggregation.tableName,
structure_version: structureVersion,
content_version: contentVersion,
last_updated_at: nowTimestamp(client),
naming_version: 2,
};
const mostRecentResult: () => Promise<LoadPreAggregationResult> = async () => {
await this.loadCache.reset(this.preAggregation);
const lastVersion = getVersionEntryByContentVersion(
await this.loadCache.getVersionEntries(this.preAggregation)
);
if (!lastVersion) {
throw new Error(`Pre-aggregation table is not found for ${this.preAggregation.tableName} after it was successfully created`);
}
const targetTableName = this.targetTableName(lastVersion);
this.updateLastTouch(targetTableName);
return {
targetTableName,
refreshKeyValues: [],
lastUpdatedAt: lastVersion.last_updated_at,
buildRangeEnd: lastVersion.build_range_end,
};
};
if (this.forceBuild) {
this.logger('Force build pre-aggregation', {
preAggregation: this.preAggregation,
requestId: this.requestId,
metadata: this.metadata,
queryKey: this.preAggregationQueryKey(invalidationKeys),
newVersionEntryView on GitHub (pinned to 7d981676b3)
Solutions
- Clear the pre-aggregation cache (or restart the instance) to purge stale version entries, then re-run the query/build.
- Check the external store/DB for the expected table name (targetTableName of lastVersion) — verify it actually exists and wasn't dropped concurrently.
- Ensure only one refresh worker builds the same pre-aggregation at a time (queue locking / single scheduler).
- Check redis/network connectivity for the orchestrator cache so reset() actually invalidates entries.
- Update to a newer Cube version; several stale-cache races around builds have been fixed.
Example fix
// before
await orchestratorApi.refreshScheduler()
// after
await orchestratorApi.getPreAggregations().preAggregationCache.forceRebuild ? null : null
// practical: clear cache then rebuild
await preAggregationsFacade.cleanup(); await preAggregationsFacade.build({ ... }) Defensive patterns
Strategy: retry
Try / catch
try {
return await loader.loadPreAggregationWithKeys();
} catch (e) {
if (String(e.message).includes('not found for') && String(e.message).includes('after it was successfully created')) {
await new Promise(r => setTimeout(r, 1000));
await loader.loadCache.reset(loader.preAggregation);
return loader.loadPreAggregationWithKeys(); // one retry after cache reset
}
throw e;
} Prevention
- Use a single refresh worker per pre-aggregation to avoid build races.
- Keep redis cache and external store consistent; monitor connectivity.
- Avoid dropping pre-aggregation tables manually while queries run.
- Upgrade Cube to pick up fixes for build/cache race conditions.
When it happens
Trigger: loadPreAggregationWithKeys completes a build, then getVersionEntries returns no versionEntryByContentVersion because the cache or table listing did not refresh; a concurrent process dropped/renamed the built table; reset did not clear a stale redis/queue entry.
Common situations: Race conditions between two refresh workers building the same pre-aggregation; cache staleness in redis when tables were built externally; partitioned pre-aggregations where expected partitions vanished between build and lookup.
Related errors
- Unable to detect column types for pre-aggregation on empty v
- Create table failed: ${e}
- Unsupported table data passed to ${this.constructor}
- Unable to import (as rows) in Cube Store: empty columns. Mos
- Unsupported export bucket type: ${this.config.bucketType}
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/0c432c602d198efe.
Report an issue: GitHub.