@@ -193,7 +193,7 @@ func (rb *redisBackend) UpdateBackfill(ctx context.Context, backfill *pb.Backfil
193
193
}
194
194
defer handleConnectionClose (& redisConn )
195
195
196
- expired , err := isBackfillExpired (redisConn , backfill .Id , getBackfillReleaseTimeout (rb .cfg ))
196
+ expired , err := isBackfillExpired (redisConn , backfill .Id , getBackfillReleaseTimeoutFraction (rb .cfg ))
197
197
if err != nil {
198
198
return err
199
199
}
@@ -332,7 +332,7 @@ func (rb *redisBackend) UpdateAcknowledgmentTimestamp(ctx context.Context, id st
332
332
}
333
333
defer handleConnectionClose (& redisConn )
334
334
335
- expired , err := isBackfillExpired (redisConn , id , getBackfillReleaseTimeout (rb .cfg ))
335
+ expired , err := isBackfillExpired (redisConn , id , getBackfillReleaseTimeoutFraction (rb .cfg ))
336
336
if err != nil {
337
337
return err
338
338
}
@@ -364,7 +364,7 @@ func (rb *redisBackend) GetExpiredBackfillIDs(ctx context.Context) ([]string, er
364
364
}
365
365
defer handleConnectionClose (& redisConn )
366
366
367
- ttl := getBackfillReleaseTimeout (rb .cfg )
367
+ ttl := getBackfillReleaseTimeoutFraction (rb .cfg )
368
368
curTime := time .Now ()
369
369
endTimeInt := curTime .Add (- ttl ).UnixNano ()
370
370
startTimeInt := 0
@@ -431,7 +431,7 @@ func (rb *redisBackend) GetIndexedBackfills(ctx context.Context) (map[string]int
431
431
}
432
432
defer handleConnectionClose (& redisConn )
433
433
434
- ttl := getBackfillReleaseTimeout (rb .cfg )
434
+ ttl := getBackfillReleaseTimeoutFraction (rb .cfg )
435
435
curTime := time .Now ()
436
436
endTimeInt := curTime .Add (time .Hour ).UnixNano ()
437
437
startTimeInt := curTime .Add (- ttl ).UnixNano ()
@@ -463,7 +463,22 @@ func (rb *redisBackend) GetIndexedBackfills(ctx context.Context) (map[string]int
463
463
}
464
464
465
465
func getBackfillReleaseTimeout (cfg config.View ) time.Duration {
466
+ const (
467
+ name = "pendingReleaseTimeout"
468
+ // Default timeout to release backfill. This value
469
+ // will be used if pendingReleaseTimeout is not configured.
470
+ defaultpendingReleaseTimeout time.Duration = 1 * time .Minute
471
+ )
472
+
473
+ if ! cfg .IsSet (name ) {
474
+ return defaultpendingReleaseTimeout
475
+ }
476
+
477
+ return cfg .GetDuration (name )
478
+ }
479
+
480
+ func getBackfillReleaseTimeoutFraction (cfg config.View ) time.Duration {
466
481
// Use a fraction 80% of pendingRelease Tickets TTL
467
- ttl := cfg . GetDuration ( "pendingReleaseTimeout" ) / 5 * 4
482
+ ttl := getBackfillReleaseTimeout ( cfg ) / 5 * 4
468
483
return ttl
469
484
}
0 commit comments