@@ -130,15 +130,25 @@ export class RepoManager implements IRepoManager {
130130 const thresholdDate = new Date ( Date . now ( ) - this . settings . reindexIntervalMs ) ;
131131 const repos = await this . db . repo . findMany ( {
132132 where : {
133- repoIndexingStatus : {
134- in : [
135- RepoIndexingStatus . NEW ,
136- RepoIndexingStatus . INDEXED
137- ]
138- } ,
139133 OR : [
140- { indexedAt : null } ,
141- { indexedAt : { lt : thresholdDate } } ,
134+ // "NEW" is really a misnomer here - it just means that the repo needs to be indexed
135+ // immediately. In most cases, this will be because the repo was just created and
136+ // is indeed "new". However, it could also be that a "retry" was requested on a failed
137+ // index. So, we don't want to block on the indexedAt timestamp here.
138+ {
139+ repoIndexingStatus : RepoIndexingStatus . NEW ,
140+ } ,
141+ // When the repo has already been indexed, we only want to reindex if the reindexing
142+ // interval has elapsed (or if the date isn't set for some reason).
143+ {
144+ AND : [
145+ { repoIndexingStatus : RepoIndexingStatus . INDEXED } ,
146+ { OR : [
147+ { indexedAt : null } ,
148+ { indexedAt : { lt : thresholdDate } } ,
149+ ] }
150+ ]
151+ }
142152 ]
143153 } ,
144154 include : {
@@ -335,7 +345,15 @@ export class RepoManager implements IRepoManager {
335345 }
336346
337347 private async onIndexJobFailed ( job : Job < RepoIndexingPayload > | undefined , err : unknown ) {
338- this . logger . info ( `Repo index job failed (id: ${ job ?. id ?? 'unknown' } )` ) ;
348+ this . logger . info ( `Repo index job failed (id: ${ job ?. id ?? 'unknown' } ) with error: ${ err } ` ) ;
349+ Sentry . captureException ( err , {
350+ tags : {
351+ repoId : job ?. data . repo . id ,
352+ jobId : job ?. id ,
353+ queue : REPO_INDEXING_QUEUE ,
354+ }
355+ } ) ;
356+
339357 if ( job ) {
340358 this . promClient . activeRepoIndexingJobs . dec ( ) ;
341359 this . promClient . repoIndexingFailTotal . inc ( ) ;
@@ -474,6 +492,13 @@ export class RepoManager implements IRepoManager {
474492
475493 private async onGarbageCollectionJobFailed ( job : Job < RepoGarbageCollectionPayload > | undefined , err : unknown ) {
476494 this . logger . info ( `Garbage collection job failed (id: ${ job ?. id ?? 'unknown' } ) with error: ${ err } ` ) ;
495+ Sentry . captureException ( err , {
496+ tags : {
497+ repoId : job ?. data . repo . id ,
498+ jobId : job ?. id ,
499+ queue : REPO_GC_QUEUE ,
500+ }
501+ } ) ;
477502
478503 if ( job ) {
479504 this . promClient . activeRepoGarbageCollectionJobs . dec ( ) ;
0 commit comments