Skip to content

Commit

Permalink
[gitpod-db] Don't consider garbage-collected prebuilds as potential b…
Browse files Browse the repository at this point in the history
…ases for incremental prebuilds
  • Loading branch information
jankeromnes authored and roboquat committed Apr 5, 2022
1 parent 760c1d5 commit 81a79af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/gitpod-db/src/typeorm/workspace-db-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ export abstract class AbstractTypeORMWorkspaceDBImpl implements WorkspaceDB {
query = query.orderBy("pws.creationTime", "DESC");
query = query.innerJoinAndMapOne("pws.workspace", DBWorkspace, "ws", "pws.buildWorkspaceId = ws.id");
query = query.andWhere("ws.deleted = false");
query = query.andWhere("ws.contentDeletedTime = ''");

const res = await query.getMany();
return res.map((r) => {
Expand Down
2 changes: 2 additions & 0 deletions components/server/ee/src/workspace/workspace-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export class WorkspaceFactoryEE extends WorkspaceFactory {
// Walk back the last prebuilds and check if they are valid ancestor.
let ws;
if (context.commitHistory && context.commitHistory.length > 0) {
// Note: This query returns only not-garbage-collected prebuilds in order to reduce cardinality
// (e.g., at the time of writing, the Gitpod repository has 16K+ prebuilds, but only ~300 not-garbage-collected)
const recentPrebuilds = await this.db
.trace({ span })
.findPrebuildsWithWorkpace(commitContext.repository.cloneUrl);
Expand Down

0 comments on commit 81a79af

Please sign in to comment.