瀏覽代碼

backfill queue: interrupt sending to deferred channel on queue re-check

If a queue re-check is requested, interrupt sending the backfill request
to the deferred channel so that immediate backfills can happen ASAP.
Sumner Evans 3 年之前
父節點
當前提交
3096786454
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      backfillqueue.go

+ 8 - 1
backfillqueue.go

@@ -40,7 +40,14 @@ func (bq *BackfillQueue) RunLoop(user *User) {
 			if backfill.BackfillType == database.BackfillImmediate || backfill.BackfillType == database.BackfillForward {
 				bq.ImmediateBackfillRequests <- backfill
 			} else {
-				bq.DeferredBackfillRequests <- backfill
+				select {
+				case <-bq.ReCheckQueue:
+					// If a queue re-check is requested, interrupt sending the
+					// backfill request to the deferred channel so that
+					// immediate backfills can happen ASAP.
+					continue
+				case bq.DeferredBackfillRequests <- backfill:
+				}
 			}
 			backfill.MarkDone()
 		} else {