Skip to content

Commit 2d4d331

Browse files
Fix bug with multiple cleanup connections being scheduled
1 parent 04022b6 commit 2d4d331

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/backend/src/repoIndexManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ export class RepoIndexManager {
149149
}
150150

151151
private async scheduleCleanupJobs() {
152-
const thresholdDate = new Date(Date.now() - this.settings.repoGarbageCollectionGracePeriodMs);
152+
const gcGracePeriodMs = new Date(Date.now() - this.settings.repoGarbageCollectionGracePeriodMs);
153+
const timeoutDate = new Date(Date.now() - this.settings.repoIndexTimeoutMs);
153154

154155
const reposToCleanup = await this.db.repo.findMany({
155156
where: {
@@ -158,9 +159,8 @@ export class RepoIndexManager {
158159
},
159160
OR: [
160161
{ indexedAt: null },
161-
{ indexedAt: { lt: thresholdDate } },
162+
{ indexedAt: { lt: gcGracePeriodMs } },
162163
],
163-
// Don't schedule if there are active jobs that were created within the threshold date.
164164
NOT: {
165165
jobs: {
166166
some: {
@@ -178,7 +178,7 @@ export class RepoIndexManager {
178178
},
179179
{
180180
createdAt: {
181-
gt: thresholdDate,
181+
gt: timeoutDate,
182182
}
183183
}
184184
]

0 commit comments

Comments
 (0)